#include <bits/stdc++.h>
int a[200010];
using namespace std;
int visit[200010];
long long INF = -400000000000010;
vector<int> edge[200010], edge0[200010];
long long sum[200010], maxsub[200010];
long long m3 = INF;
void dfs0(int x) {
  visit[x] = 1;
  for (int i = 0; i < edge0[x].size(); i++) {
    if (visit[edge0[x][i]]) continue;
    edge[x].push_back(edge0[x][i]);
    dfs0(edge0[x][i]);
  }
}
long long dfs1(int x) {
  long long ans = 0;
  for (int i = 0; i < edge[x].size(); i++) {
    ans += dfs1(edge[x][i]);
  }
  return sum[x] = ans + a[x];
}
long long dfs2(int x) {
  long long ans = INF;
  for (int i = 0; i < edge[x].size(); i++) {
    ans = max(ans, dfs2(edge[x][i]));
  }
  ans = max(ans, sum[x]);
  return maxsub[x] = ans;
}
void dfs3(int x) {
  if (edge[x].size() < 2) {
    for (int i = 0; i < edge[x].size(); i++) {
      dfs3(edge[x][i]);
    }
    return;
  }
  long long m1 = INF, m2 = INF;
  for (int i = 0; i < edge[x].size(); i++) {
    dfs3(edge[x][i]);
    long long tmp = maxsub[edge[x][i]];
    if (tmp >= m1) {
      m2 = m1;
      m1 = tmp;
    } else if (tmp >= m2) {
      m2 = tmp;
    }
  }
  if (m1 + m2 > m3) m3 = m1 + m2;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edge0[u].push_back(v);
    edge0[v].push_back(u);
  }
  dfs0(1);
  dfs1(1);
  dfs2(1);
  dfs3(1);
  if (m3 == INF)
    cout << "Impossible";
  else
    cout << m3;
}
