#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9;
const long long BIG = 1e18;
vector<vector<int> > g(N);
long long a[N], sum[N], max_sum[N], ans = -BIG;
void dfs(int v = 1, int p = -1) {
  sum[v] = a[v];
  max_sum[v] = -BIG;
  for (auto to : g[v]) {
    if (to == p) continue;
    dfs(to, v);
    sum[v] += sum[to];
    max_sum[v] = max(max_sum[v], max_sum[to]);
  }
  max_sum[v] = max(max_sum[v], sum[v]);
}
void calc(int v = 1, int p = -1, long long out = -BIG) {
  if (out != -BIG) {
    ans = max(ans, sum[v] + out);
  }
  vector<pair<long long, int> > val;
  for (auto to : g[v]) {
    if (to == p) continue;
    val.push_back(make_pair(max_sum[to], to));
  }
  val.push_back(make_pair(-BIG, -1));
  sort(val.begin(), val.end());
  reverse(val.begin(), val.end());
  for (auto to : g[v]) {
    if (to == p) continue;
    long long choice = 0ll;
    if (val[0].second == to)
      choice = val[1].first;
    else
      choice = val[0].first;
    calc(to, v, max(out, choice));
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n, m;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v), g[v].push_back(u);
  }
  dfs();
  calc();
  if (ans == -BIG)
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
