#include <bits/stdc++.h>
using namespace std;
long long n, a[200005];
vector<long long> edge[200005];
long long bestOne[200005];
long long cutVal[200005];
bool impossible = true;
long long res = -1e9;
bool seen[200005];
void solve(long long ind, long long parent) {
  if (edge[ind].empty()) return;
  if (seen[ind]) return;
  seen[ind] = true;
  if (parent != -1 && edge[ind].size() == 1) {
    bestOne[ind] = a[ind];
    cutVal[ind] = a[ind];
    return;
  }
  vector<long long> twoBest;
  for (int i = 0; i < edge[ind].size(); i++) {
    if (edge[ind][i] != parent) {
      solve(edge[ind][i], ind);
      twoBest.push_back(bestOne[edge[ind][i]]);
      cutVal[ind] += cutVal[edge[ind][i]];
    }
  }
  sort(twoBest.begin(), twoBest.end(), greater<long long>());
  cutVal[ind] += a[ind];
  bestOne[ind] = max(twoBest[0], cutVal[ind]);
  if (twoBest.size() >= 2) {
    long long val = twoBest[0] + twoBest[1];
    if (impossible) {
      impossible = false;
      res = val;
    } else {
      res = max(res, val);
    }
  }
}
int main() {
  fill(bestOne, bestOne + 200005, -1e16);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  solve(1, -1);
  if (impossible) {
    cout << "Impossible" << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}
