#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200000];
int n;
vector<int> a;
long long ones[200000];
long long twos[200000];
long long subsum[200000];
long long totans = LLONG_MIN;
void dfs(int no, int last) {
  vector<int> chil;
  for (int i = 0; i < (int((adj[no]).size())); ++i) {
    int to = adj[no][i];
    if (last == to) continue;
    dfs(to, no);
    chil.push_back(to);
    subsum[no] += subsum[to];
  }
  subsum[no] += a[no];
  if (int((chil).size()) == 0) {
    ones[no] = a[no];
    twos[no] = LLONG_MIN;
    subsum[no] = a[no];
    return;
  }
  long long bans = LLONG_MIN;
  for (int i = 0; i < (int((chil).size())); ++i) {
    bans = max(bans, ones[chil[i]]);
  }
  bans = max(bans, subsum[no]);
  ones[no] = bans;
  vector<long long> sorto;
  for (int i = 0; i < (int((chil).size())); ++i) {
    sorto.push_back(ones[chil[i]]);
  }
  sort((sorto).begin(), (sorto).end());
  reverse((sorto).begin(), (sorto).end());
  long long anso = LLONG_MIN;
  if (int((sorto).size()) >= 2) anso = max(anso, sorto[0] + sorto[1]);
  for (int i = 0; i < (int((chil).size())); ++i) {
    anso = max(anso, twos[chil[i]]);
  }
  twos[no] = anso;
  totans = max(totans, anso);
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    int nxt;
    cin >> nxt;
    a.push_back(nxt);
  }
  for (int i = 0; i < (n - 1); ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0, -1);
  for (int i = 0; i < (n); ++i) {
  }
  if (totans == LLONG_MIN)
    cout << "Impossible" << endl;
  else
    cout << totans << endl;
}
