#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long inf = 1LL << 62;
long long a[N], b[N];
vector<int> tree[N];
void dfs(int u, int f) {
  b[u] = a[u];
  for (int i = 0; i < (int)tree[u].size(); i++) {
    int v = tree[u][i];
    if (v == f) continue;
    dfs(v, u);
    b[u] += b[v];
  }
}
void dfs(int u, int f, long long& x, long long& y, long long& z) {
  x = -inf;
  y = -inf;
  z = b[u];
  vector<pair<long long, long long> > vec;
  for (int i = 0; i < (int)tree[u].size(); i++) {
    int v = tree[u][i];
    if (v == f) continue;
    long long vx, vy, vz;
    dfs(v, u, vx, vy, vz);
    if (x < vz)
      y = x, x = vz;
    else
      y = max(y, vz);
    z = max(z, vz);
    vec.push_back(pair<long long, long long>(vx, vy));
  }
  for (int i = 0; i < (int)vec.size(); i++) {
    long long first = vec[i].first, second = vec[i].second;
    if (first + second > x + y) x = first, y = second;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%I64d", a + i);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  dfs(1, 0);
  long long res1, res2, res3;
  dfs(1, 0, res1, res2, res3);
  if (res2 == -inf)
    puts("Impossible");
  else
    cout << res1 + res2 << endl;
  return 0;
}
