#include <bits/stdc++.h>
using namespace std;
vector<int> g[200001];
long long ans[200001];
long long a[200001];
long long sum[200001];
int u[200001];
int pr[200001];
void dfs(int v) {
  u[v] = 1;
  sum[v] = a[v];
  for (int i = 0; i < g[v].size(); i++) {
    if (!u[g[v][i]]) {
      pr[g[v][i]] = v;
      dfs(g[v][i]);
      sum[v] += sum[g[v][i]];
      ans[v] = max(ans[g[v][i]], ans[v]);
    }
  }
  ans[v] = max(ans[v], sum[v]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans[i] = -1000000000000001;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  bool ok = 0;
  int start;
  long long wer = -1000000000000001;
  for (int i = 1; i <= n; i++) {
    if ((i == 1 && g[i].size() >= 2) || (g[i].size() >= 3)) {
      ok = 1;
      start = i;
      long long almas = -1000000000000001;
      long long almass = -1000000000000001;
      int pos = 0;
      for (int j = 0; j < g[start].size(); j++) {
        if (g[start][j] == pr[start]) continue;
        if (ans[g[start][j]] > almas) {
          almas = ans[g[start][j]];
          pos = j;
        }
      }
      for (int j = 0; j < g[start].size(); j++) {
        if (g[start][j] == pr[start]) continue;
        if (ans[g[start][j]] > almass && pos != j) {
          almass = ans[g[start][j]];
        }
      }
      wer = max(wer, almas + almass);
    }
  }
  if (!ok) {
    cout << "Impossible";
    ;
    return 0;
  }
  cout << wer;
  return 0;
}
