#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e17;
const int N = 3e5 + 7;
int n, m;
int c[N];
vector<int> g[N];
long long w[N], sum = -inf, f[N];
bool imp = true;
void dfs(int v, int p) {
  w[v] += c[v];
  int cnt = 0;
  for (int u : g[v]) {
    if (u != p) {
      dfs(u, v);
      f[v] = max(f[u], f[v]);
      w[v] += w[u];
      cnt++;
    }
  }
  if (cnt > 1) imp = false;
  f[v] = max(f[v], w[v]);
  long long mx1 = -inf, mx2 = -inf;
  for (int u : g[v]) {
    if (u == p) continue;
    long long cur = f[u];
    if (mx1 < cur) swap(mx1, cur);
    if (mx2 < cur) swap(mx2, cur);
  }
  if (mx2 > -inf) sum = max(sum, mx1 + mx2);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", c + i);
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < N; i++) {
    f[i] = -inf;
  }
  dfs(0, -1);
  if (imp == true)
    printf("Impossible\n");
  else
    printf("%lld\n", sum);
  return 0;
}
