#include <bits/stdc++.h>
using namespace std;
int const N = 2 * 100 * 1000 + 16;
int n;
long long mx[N];
long long sum[N];
long long best = -8e18;
vector<int> g[N];
void dfs(int u = 1, int p = 0) {
  sum[u] = mx[u];
  mx[u] = -9e18;
  long long x = -4e18, y = -4e18;
  for (int v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    sum[u] += sum[v];
    mx[u] = max(mx[u], mx[v]);
    if (y < mx[v])
      x = y, y = mx[v];
    else if (x < mx[v])
      x = mx[v];
  }
  mx[u] = max(mx[u], sum[u]);
  best = max(best, x + y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld", mx + i);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  dfs();
  if (best < -1e18)
    puts("Impossible");
  else
    printf("%lld\n", best);
}
