#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000000000007LL;
vector<vector<long long> > adj(200200);
long long ans[200200], val[200200];
long long finalAns;
void dfs(int u, int p) {
  long long mx1 = -MOD, mx2 = -MOD, sum = 0;
  for (int i = 0; i < adj[u].size(); i++) {
    int cur = adj[u][i];
    if (cur == p) continue;
    dfs(cur, u);
    if (ans[cur] >= mx1) {
      mx2 = mx1;
      mx1 = ans[cur];
    } else if (ans[cur] >= mx2) {
      mx2 = ans[cur];
    }
    sum += val[cur];
  }
  val[u] += sum;
  ans[u] = max(mx1, val[u]);
  if (mx2 != -MOD) {
    finalAns = max(finalAns, mx1 + mx2);
  }
}
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
  }
  for (int i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  finalAns = -MOD;
  dfs(1, -1);
  if (finalAns == -MOD) {
    cout << "Impossible\n";
  } else {
    cout << finalAns << "\n";
  }
  return 0;
}
