#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 200;
vector<int> g[maxn];
long long val[maxn];
long long sum[maxn];
long long ma[maxn];
long long ans = -1e18;
int n, dep;
void dfs0(int u, int fa) {
  dep++;
  if (dep == n) {
    n = -1;
    return;
  }
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs0(v, u);
    dep--;
  }
}
void dfs1(int u, int fa) {
  int x = (int)g[u].size();
  sum[u] = val[u];
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs1(v, u);
    sum[u] += sum[v];
    ma[u] = max(ma[u], ma[v]);
  }
  ma[u] = max(ma[u], sum[u]);
  if (x == 1) return;
  long long ans1 = -1e17, ans2 = -1e17;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (ma[v] <= ans2)
      continue;
    else if (ma[v] >= ans1) {
      ans2 = ans1;
      ans1 = ma[v];
    } else
      ans2 = ma[v];
  }
  ans = max(ans, ans1 + ans2);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &val[i]);
  for (int i = 1; i <= n; i++) ma[i] = -1e18;
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs0(1, -1);
  if (n == -1) {
    printf("Impossible\n");
    return 0;
  }
  dfs1(1, -1);
  printf("%I64d\n", ans);
  return 0;
}
