#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> mx[200005];
long long sum[200005];
vector<long long> g[200005];
bool vis[200005];
long long ans = -1e16;
long long getsum(int ver) {
  vis[ver] = true;
  for (int i = 0; i < g[ver].size(); i++) {
    int child = g[ver][i];
    if (vis[child]) continue;
    sum[ver] += getsum(child);
  }
  return sum[ver];
}
void getmax(int ver) {
  vis[ver] = true;
  for (int i = 0; i < g[ver].size(); i++) {
    int child = g[ver][i];
    if (vis[child]) continue;
    getmax(child);
    long long mx1 = -1e16;
    long long mx2 = -1e16;
    if (sum[child] >= mx[child].first && sum[child] >= mx[child].second)
      mx2 = sum[child];
    else
      mx1 = mx[child].first, mx2 = mx[child].second;
    long long arr[4];
    arr[0] = mx1, arr[1] = mx2, arr[2] = mx[ver].first, arr[3] = mx[ver].second;
    sort(arr, arr + 4);
    mx[ver].first = arr[2], mx[ver].second = arr[3];
  }
  ans = max(ans, mx[ver].first + mx[ver].second);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%lld", &sum[i]);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) mx[i].first = -1e16, mx[i].second = -1e16;
  sum[1] = getsum(1);
  memset(vis, 0, sizeof(vis));
  getmax(1);
  if (ans < -200000000000000)
    cout << "Impossible";
  else
    cout << ans;
}
