#include <bits/stdc++.h>
using namespace std;
struct node {
  long long next;
  long long t;
  long long w;
} edge[400005];
struct node1 {
  long long w;
  long long pos;
} p[400005];
long long head[400005], vis[400005];
long long n, tot;
void addedge(long long u, long long v) {
  edge[++tot].next = head[u];
  edge[tot].t = v;
  head[u] = tot;
}
long long maxn1 = -1e18, maxn2 = -1e18;
void dfs1(long long now) {
  for (int i = head[now]; i; i = edge[i].next) {
    if (!vis[edge[i].t]) {
      vis[edge[i].t] = 1;
      dfs1(edge[i].t);
      p[now].w += p[edge[i].t].w;
    }
  }
}
void dfs2(long long now) {
  for (int i = head[now]; i; i = edge[i].next) {
    if (!vis[edge[i].t]) {
      vis[edge[i].t] = 1;
      if (maxn1 != -1e18) maxn2 = max(maxn2, maxn1 + p[edge[i].t].w);
      dfs2(edge[i].t);
      maxn1 = max(maxn1, p[edge[i].t].w);
    }
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &p[i].w);
    p[i].pos = i;
  }
  long long x, y;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%lld %lld", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  vis[1] = 1;
  dfs1(1);
  memset(vis, 0, sizeof(vis));
  vis[1] = 1;
  dfs2(1);
  if (maxn2 != -1e18)
    printf("%lld\n", maxn2);
  else
    printf("Impossible\n");
}
