#include <bits/stdc++.h>
using namespace std;
vector<long long> V[200100];
long long D[200100][3], sum[200100], a[200100], N;
void DFS(long long n, long long p) {
  long long i, j, max2, max11, max12, max11w;
  max2 = max11 = max12 = -4e18;
  sum[n] += a[n];
  for (i = 0; i < V[n].size(); i++) {
    if (V[n][i] == p) continue;
    DFS(V[n][i], n);
    sum[n] += sum[V[n][i]];
    max2 = max(max2, D[V[n][i]][2]);
    if (max11 < D[V[n][i]][1]) max11w = i;
    max11 = max(max11, D[V[n][i]][1]);
  }
  for (i = 0; i < V[n].size(); i++) {
    if (V[n][i] == p || max11w == i) continue;
    max12 = max(max12, D[V[n][i]][1]);
  }
  D[n][0] = max(D[n][0], 0LL), D[n][1] = max(D[n][1], max(sum[n], max11)),
  D[n][2] = max(D[n][2], max(max2, max11 + max12));
}
int main() {
  long long i, j;
  cin >> N;
  for (i = 1; i <= N; i++) cin >> a[i];
  for (i = 1; i <= N; i++)
    for (j = 0; j <= 2; j++) D[i][j] = -2e18;
  for (i = 0; i < N - 1; i++) {
    long long x, y;
    cin >> x >> y;
    V[x].push_back(y);
    V[y].push_back(x);
  }
  DFS(1, 1);
  if (D[1][2] == -2e18)
    cout << "Impossible";
  else
    cout << D[1][2];
}
