#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 2e5 + 10;
const long long mod = 998244353;
const int inf = 0x3ffffff;
const double eps = 1e-5;
long long a[maxn], res[maxn];
int n;
vector<long long> G[maxn], h[maxn];
long long maxnum = LLONG_MIN;
bool cmp(long long a, long long b) { return a > b; }
void dfs(int now, int fath) {
  for (int i = 0; i < G[now].size(); i++) {
    int v = G[now][i];
    if (v != fath) {
      dfs(v, now);
      a[now] += a[v];
    }
  }
}
void dfs1(int now, int fath) {
  for (int i = 0; i < G[now].size(); i++) {
    int v = G[now][i];
    if (v != fath) {
      dfs1(v, now);
      res[now] = max(res[v], res[now]);
      h[now].push_back(res[v]);
    }
  }
  sort(h[now].begin(), h[now].end(), cmp);
  if (h[now].size() >= 2) maxnum = max(maxnum, h[now][0] + h[now][1]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  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);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    res[i] = a[i];
  }
  dfs1(1, 0);
  if (maxnum == LLONG_MIN)
    cout << "Impossible";
  else
    cout << maxnum;
  return ~~(0 - 0);
}
