#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int vis[200001];
long long int res, a[200001];
pair<long long int, long long int> dfs(int i) {
  vis[i] = 1;
  if (adj[i].size() == 1 && i) return make_pair(a[i], a[i]);
  int j;
  long long int l, r, xsum, ysum;
  pair<long long int, long long int> p;
  l = r = LLONG_MIN;
  xsum = 0;
  for (j = 0; j < adj[i].size(); j++)
    if (!vis[adj[i][j]]) {
      p = dfs(adj[i][j]);
      if (l == LLONG_MIN)
        l = p.first;
      else {
        r = max(r, p.first);
        if (l < r) swap(l, r);
      }
      xsum += p.second;
    }
  if (r == LLONG_MIN)
    r = 0;
  else
    res = max(res, l + r);
  return make_pair(max(l, a[i] + xsum), a[i] + xsum);
}
int main() {
  int n, u, v, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    vis[i] = 0;
    cin >> a[i];
  }
  for (i = 1; i < n; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  res = LLONG_MIN;
  dfs(0);
  if (res == LLONG_MIN)
    cout << "Impossible";
  else
    cout << res;
  return 0;
}
