#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int vis[200005];
long long arr[200005];
long long su[200005];
long long dp[200005];
int n;
int cou;
long long fin;
long long bes1, bes2;
const long long INF = 1E16;
void dfs(int ind) {
  vis[ind] = 1;
  dp[ind] = -INF;
  su[ind] = arr[ind];
  vector<long long> vec;
  for (int i = 0; i < v[ind].size(); i++) {
    if (!vis[v[ind][i]]) {
      dfs(v[ind][i]);
      su[ind] += su[v[ind][i]];
      dp[ind] = max(dp[v[ind][i]], dp[ind]);
      vec.push_back(dp[v[ind][i]]);
    }
  }
  dp[ind] = max(dp[ind], su[ind]);
  if (vec.size() >= 2) {
    cou = 1;
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    long long xx = vec[0] + vec[1];
    if (xx > fin) {
      fin = xx;
    }
  }
}
int main() {
  scanf("%d", &n);
  int i, j;
  bes1 = bes2 = fin = -INF;
  for (i = 1; i <= n; i++) scanf("%I64d", &arr[i]);
  for (i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1);
  if (cou == 1)
    printf("%I64d\n", fin);
  else
    printf("Impossible\n");
}
