#include <bits/stdc++.h>
using namespace std;
const int MN = 200 * 1000 + 200;
vector<int> adj[MN];
long long dpd[MN];
long long dpdmx[MN];
long long dpu[MN];
long long a[MN];
long long dps[MN][2];
void dfs1(int v, int p) {
  dps[v][0] = -1e17;
  dps[v][1] = -1e17;
  dpd[v] += a[v];
  for (int u : adj[v]) {
    if (u != p) {
      dfs1(u, v);
      dpd[v] += dpd[u];
      dpdmx[v] = max(dpdmx[v], dpdmx[u]);
      if (dpdmx[u] > dps[v][1]) dps[v][1] = dpdmx[u];
      if (dps[v][1] > dps[v][0]) swap(dps[v][1], dps[v][0]);
    }
  }
  dpdmx[v] = max(dpdmx[v], dpd[v]);
}
void dfs2(int v, int p) {
  if (v != p) {
    if (dps[p][0] == dpdmx[v]) {
      dpu[v] = max(dpu[p], dps[p][1]);
    } else {
      dpu[v] = max(dpu[p], dps[p][0]);
    }
  } else {
    dpu[v] = -1e17;
  }
  for (int u : adj[v]) {
    if (u != p) dfs2(u, v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  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);
  }
  fill(dpdmx, dpdmx + n, -1e17);
  dfs1(0, 0);
  fill(dpu, dpu + n, -1e17);
  dfs2(0, 0);
  long long ans = -1e17;
  for (int i = 0; i < n; i++) {
    ans = max(ans, dpu[i] + dpdmx[i]);
  }
  if (ans <= -1e16) {
    cout << "Impossible";
  } else {
    cout << ans;
  }
}
