#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 2e5 + 5;
const LL INF = -1e17;
vector<int> g[N];
int n;
LL a[N], ans[N], mx[N], tot[N];
void dp(int u, int p) {
  ans[u] = INF, mx[u] = INF, tot[u] = a[u];
  LL x = INF, y = INF;
  for (auto v : g[u])
    if (v != p) {
      dp(v, u);
      ans[u] = max(ans[u], ans[v]);
      tot[u] += tot[v];
      mx[u] = max(mx[u], mx[v]);
      if (mx[v] > x)
        y = x, x = mx[v];
      else
        y = max(y, mx[v]);
    }
  mx[u] = max(tot[u], mx[u]);
  if (y > INF) ans[u] = max(ans[u], x + y);
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%lld", &a[i]);
  for (int i = (1); i <= (n - 1); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dp(1, 0);
  if (ans[1] <= INF)
    printf("Impossible\n");
  else
    printf("%lld\n", ans[1]);
}
