#include <bits/stdc++.h>
using namespace std;
static const int max_n = (2e+5) + 1;
static const long long INF = 1e+17;
static const long long INF_M = -INF;
static const long long INF_M_2 = 2 * INF_M;
int pleasant[max_n] = {};
long long pleasant_sub[max_n] = {};
vector<int> conns[max_n];
long long dp1[max_n];
long long dp2[max_n];
long long dp[max_n][3];
int n;
long long dfs_pleasant(int node, int p) {
  long long& s = pleasant_sub[node];
  if (s == INF_M) {
    int len = conns[node].size();
    s = pleasant[node];
    for (int i = 0; i < len; ++i) {
      if (conns[node][i] != p) {
        s += dfs_pleasant(conns[node][i], node);
      }
    }
  }
  return s;
}
long long dfs(int node, int p, int remain = 2) {
  long long& s = dp[node][remain];
  if (s == INF_M_2) {
    int len = conns[node].size();
    if (remain == 2) {
      long long max1_1 = INF_M;
      long long max1_2 = INF_M;
      long long max2 = INF_M;
      long long p1;
      for (int i = 0; i < len; ++i) {
        if (conns[node][i] != p) {
          p1 = pleasant_sub[conns[node][i]];
          p1 = max(p1, dfs(conns[node][i], node, 1));
          max2 = max(max2, dfs(conns[node][i], node, 2));
          if (p1 > max1_1) {
            max1_2 = max1_1;
            max1_1 = p1;
          } else if (p1 > max1_2) {
            max1_2 = p1;
          }
        }
      }
      long long max1;
      if (max1_2 == INF_M or max1_1 == INF_M)
        max1 = INF_M;
      else
        max1 = max1_1 + max1_2;
      s = max(max1, max2);
    } else {
      long long max1 = INF_M;
      for (int i = 0; i < len; ++i) {
        if (conns[node][i] != p) {
          max1 = max(max1, pleasant_sub[conns[node][i]]);
          max1 = max(max1, dfs(conns[node][i], node, 1));
        }
      }
      s = max1;
    }
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i < n + 1; ++i) cin >> pleasant[i];
  int x, y;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    conns[x].push_back(y);
    conns[y].push_back(x);
  }
  for (int i = 1; i < n + 1; ++i) {
    pleasant_sub[i] = INF_M;
    dp[i][1] = INF_M_2;
    dp[i][2] = INF_M_2;
  }
  dfs_pleasant(1, -1);
  long long ans = dfs(1, -1);
  if (ans == INF_M)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
}
