#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
const int N = 2e5 + 3;
long long ans = -INF;
int n;
long long a[N];
vector<int> g[N];
long long mx = -INF;
void DFS1(int u, int par) {
  for (size_t i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v != par) {
      DFS1(v, u);
      a[u] += a[v];
    }
  }
}
void DFS2(int u, int par) {
  if (mx != -INF) ans = max(ans, a[u] + mx);
  for (size_t i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v != par) {
      DFS2(v, u);
    }
  }
  mx = max(a[u], mx);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  DFS1(1, -1);
  DFS2(1, -1);
  if (ans != -INF)
    cout << ans;
  else
    cout << "Impossible";
  return 0;
}
