#include <bits/stdc++.h>
using namespace std;
vector<int> tree[200010];
long long a[200010];
long long sumx[200010];
long long mxx[200010];
long long gl;
void dfs(int v, int par) {
  long long ans = a[v];
  for (int i = 0; i < tree[v].size(); i++) {
    int u = tree[v][i];
    if (u != par) {
      dfs(u, v);
      ans += sumx[u];
    }
  }
  sumx[v] = ans;
}
void dfs2(int v, int par) {
  long long ans = sumx[v];
  for (int i = 0; i < tree[v].size(); i++) {
    int u = tree[v][i];
    if (u != par) {
      dfs2(u, v);
      ans = max(ans, mxx[u]);
    }
  }
  mxx[v] = ans;
}
void dfs3(int v, int par) {
  vector<long long> vc;
  for (int i = 0; i < tree[v].size(); i++) {
    int u = tree[v][i];
    if (u != par) {
      vc.push_back(mxx[u]);
      dfs3(u, v);
    }
  }
  if (vc.size() >= 2) {
    sort(vc.begin(), vc.end());
    int oo = vc.size();
    gl = max(gl, vc[oo - 1] + vc[oo - 2]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, u, v;
  cin >> n;
  int i, j;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  dfs(1, -1);
  dfs2(1, -1);
  gl = LLONG_MIN;
  dfs3(1, -1);
  if (gl == LLONG_MIN)
    cout << "Impossible";
  else {
    cout << gl;
  }
}
