#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> row;
  vector<vector<int>> g(n, row);
  vector<vector<int>> tree(n, row);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  queue<int> q;
  vector<int> vis(n, 0);
  vector<int> lot;
  vis[0] = 1;
  lot.push_back(0);
  q.push(0);
  while (!q.empty()) {
    int curr = q.front();
    q.pop();
    for (int i = 0; i < g[curr].size(); i++) {
      int vtx = g[curr][i];
      if (!vis[vtx]) {
        vis[vtx] = 1;
        lot.push_back(vtx);
        tree[curr].push_back(vtx);
        q.push(vtx);
      }
    }
  }
  vector<long long> dp_sum(n, 0);
  vector<long long> dp_max(n, 0);
  for (int i = n - 1; i >= 0; i--) {
    int curr = lot[i];
    dp_sum[curr] = (long long)a[curr];
    for (int j = 0; j < tree[curr].size(); j++)
      dp_sum[curr] += dp_sum[tree[curr][j]];
    dp_max[curr] = dp_sum[curr];
    for (int j = 0; j < tree[curr].size(); j++)
      dp_max[curr] = max(dp_max[curr], dp_max[tree[curr][j]]);
  }
  int flag = 0;
  vector<long long> dp_ans(n, -1000000000000000000);
  long long ans = -1000000000000000000;
  for (int i = 0; i < n; i++) {
    int curr = lot[i];
    vector<long long> cand;
    for (int j = 0; j < tree[curr].size(); j++) {
      int vtx = tree[curr][j];
      cand.push_back(dp_max[vtx]);
    }
    sort(cand.begin(), cand.end());
    if (!cand.size()) continue;
    for (int j = 0; j < tree[curr].size(); j++) {
      int vtx = tree[curr][j];
      dp_ans[vtx] = dp_ans[curr];
      if (dp_max[vtx] == cand[(int)cand.size() - 1] && cand.size() > 1)
        dp_ans[vtx] = max(dp_ans[vtx], cand[(int)cand.size() - 2]);
      else if (cand.size() > 1)
        dp_ans[vtx] = max(dp_ans[vtx], cand[(int)cand.size() - 1]);
      ans = max(ans, dp_ans[vtx] + dp_sum[vtx]);
    }
  }
  if (ans < -10000000000000000)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
  return 0;
}
