#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 22;
const long long INF = 2e18 + 2;
int n;
long long res = -INF * 2;
long long a[MAXN], mx[MAXN], sum[MAXN];
vector<int> G[MAXN];
void dfs(int v, int par) {
  sum[v] = a[v];
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == par) continue;
    dfs(u, v);
    sum[v] += sum[u];
    mx[v] = max(mx[v], mx[u]);
  }
  mx[v] = max(mx[v], sum[v]);
}
void dfs2(int v, int par) {
  vector<long long> vec;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == par) continue;
    dfs2(u, v);
    vec.push_back(mx[u]);
    if (vec.size() > 2) {
      sort(vec.rbegin(), vec.rend());
      vec.pop_back();
    }
  }
  if (vec.size() < 2) return;
  res = max(res, vec[0] + vec[1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) mx[i] = -INF;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0, x, y; i < n - 1; i++) {
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(0, -1);
  dfs2(0, -1);
  if (res != -INF * 2)
    cout << res;
  else
    cout << "Impossible";
  return 0;
}
