#include <bits/stdc++.h>
using namespace std;
long long inf = -(long long)1e15;
int a[200001];
int n;
vector<int> adj[200001];
long long sum[200001], dp1[200001], dp2[200001];
void dfs(int cur, int prev) {
  sum[cur] = a[cur];
  for (auto nxt : adj[cur]) {
    if (nxt == prev) continue;
    dfs(nxt, cur);
    sum[cur] += sum[nxt];
  }
  dp1[cur] = sum[cur];
  dp2[cur] = inf;
  vector<long long> tmp;
  for (auto nxt : adj[cur]) {
    if (nxt == prev) continue;
    dp1[cur] = max(dp1[cur], dp1[nxt]);
    dp2[cur] = max(dp2[cur], dp2[nxt]);
    tmp.push_back(dp1[nxt]);
  }
  sort(tmp.rbegin(), tmp.rend());
  if (tmp.size() >= 2) dp2[cur] = max(dp2[cur], tmp[0] + tmp[1]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, -1);
  if (dp2[1] == inf) {
    puts("Impossible");
  } else {
    cout << dp2[1] << endl;
  }
}
