#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
const int MAXN = 1e5 + 10;
int mod = 1e9 + 7;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int a[3000005];
vector<int> adj[400000];
long long best[400000];
long long sum[400000];
long long ans = -1e16;
long long dfs1(int node = 0, int par = -1) {
  sum[node] = a[node];
  for (auto i : adj[node])
    if (i != par) sum[node] += dfs1(i, node);
  return sum[node];
}
pair<long long, long long> fun(int node = 0, int par = -1) {
  vector<long long> v(4, -1e16);
  for (auto i : adj[node])
    if (i != par) {
      pair<long long, long long> ret = fun(i, node);
      v[0] = ret.first;
      v[1] = ret.second;
      sort(v.begin(), v.end());
    }
  ans = max(ans, v[2] + v[3]);
  if (sum[node] > v[3]) v[3] = sum[node], v[2] = -1e16;
  return {v[2], v[3]};
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, x, y;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs1();
  fun();
  if (ans < -1e14)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
}
