#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16 + 7;
long long n, ans = -inf;
int a[200001];
long long sum[200001], maxx[200001];
bool vis[200001];
vector<vector<int> > lst;
void dfs(int i) {
  long long ans1 = -inf, ans2 = -inf;
  vis[i] = 1;
  for (int j = 0; j < lst[i].size(); j++) {
    if (!vis[lst[i][j]]) {
      dfs(lst[i][j]);
      sum[i] += sum[lst[i][j]];
      maxx[i] = max(maxx[i], max(maxx[lst[i][j]], sum[lst[i][j]]));
      if (ans1 < max(maxx[lst[i][j]], sum[lst[i][j]])) {
        ans2 = ans1;
        ans1 = max(maxx[lst[i][j]], sum[lst[i][j]]);
      } else if (ans2 < max(maxx[lst[i][j]], sum[lst[i][j]])) {
        ans2 = max(maxx[lst[i][j]], sum[lst[i][j]]);
      }
    }
  }
  if (ans1 + ans2 > ans && ans1 != -inf && ans2 != -inf) {
    ans = ans1 + ans2;
  }
}
int main() {
  cin >> n;
  lst.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i] = a[i];
    maxx[i] = -inf;
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    lst[a - 1].push_back(b - 1);
    lst[b - 1].push_back(a - 1);
  }
  dfs(0);
  if (ans == -inf) {
    cout << "Impossible";
    return 0;
  }
  cout << ans << endl;
}
