#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const long long INFF = 0x7fffffffffffffff;
const double pi = 3.141592653589793;
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
struct edges {
  int to;
  int next;
} edge[1000005];
long long mx = -INFF;
int head[1000005];
int cnt = 0;
long long a[1000005];
long long value1[1000005];
void makeedge(int u, int v) {
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
int vis[1000005];
long long value[1000005];
bool flag = false;
long long dfs(int u) {
  vis[u] = 1;
  value[u] = a[u];
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if (!vis[v]) {
      value[u] += dfs(v);
    }
  }
  return value[u];
}
long long dfs2(int u) {
  vis[u] = 1;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if (!vis[v]) {
      value[u] = max(value[u], dfs2(v));
    }
  }
  return value[u];
}
void bfs1(int u) {
  queue<int> q;
  q.push(1);
  vis[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    vis[u] = 1;
    q.pop();
    int cnt1 = 0;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      if (!vis[edge[i].to]) {
        value1[cnt1++] = value[edge[i].to];
        q.push(edge[i].to);
      }
    }
    if (cnt1 >= 2) {
      flag = true;
      sort(value1, value1 + cnt1);
      mx = max(mx, value1[cnt1 - 1] + value1[cnt1 - 2]);
    }
  }
}
int main() {
  int n;
  memset(head, -1, sizeof(head));
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    makeedge(u, v);
    makeedge(v, u);
  }
  memset(vis, 0, sizeof(vis));
  memset(value, 0, sizeof(value));
  dfs(1);
  memset(vis, 0, sizeof(vis));
  dfs2(1);
  memset(vis, 0, sizeof(vis));
  bfs1(1);
  if (!flag)
    cout << "Impossible" << endl;
  else
    cout << mx << endl;
  return 0;
}
