#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
long long inf = 1e18;
int n;
vector<int> v[N];
vector<int> tree[N];
long long a[N];
long long sm[N];
bool was[N];
long long ans = -1e18;
void podves(int i) {
  was[i] = true;
  for (int j : v[i])
    if (!was[j]) {
      tree[i].push_back(j);
      podves(j);
    }
}
void dfs(int i) {
  sm[i] = a[i];
  for (int j : tree[i]) {
    dfs(j);
    sm[i] += sm[j];
  }
}
void dfs2(int i) {
  long long mx1 = -inf, mx2 = -inf;
  for (int j : tree[i]) {
    dfs2(j);
    if (sm[j] > mx1) {
      mx2 = mx1;
      mx1 = sm[j];
    } else if (sm[j] > mx2)
      mx2 = sm[j];
  }
  if (mx2 != -inf) ans = max(ans, mx1 + mx2);
  sm[i] = max(sm[i], mx1);
}
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  fill(was, was + n, false);
  podves(0);
  dfs(0);
  dfs2(0);
  if (ans == -inf)
    cout << "Impossible\n";
  else
    cout << ans << endl;
}
