#include <bits/stdc++.h>
using namespace std;
const int MAXN = 222222;
vector<int> E[MAXN];
int a[MAXN];
long long dp[MAXN];
long long s[MAXN];
int dad[MAXN];
long long ans = -(1LL << 60);
void check_ans(int node) {
  vector<long long> best;
  for (int i = 0; i < E[node].size(); i++) {
    int to = E[node][i];
    if (to == dad[node]) continue;
    best.push_back(dp[to]);
  }
  if (best.size() >= 2) {
    sort(best.begin(), best.end());
    int sz = best.size();
    ans = max(ans, best[sz - 1] + best[sz - 2]);
  }
}
void dfs(int node, int d = -1) {
  dad[node] = d;
  s[node] = a[node];
  for (int i = 0; i < E[node].size(); i++) {
    int to = E[node][i];
    if (d == to) continue;
    dfs(to, node);
    s[node] += s[to];
  }
  dp[node] = s[node];
  for (int i = 0; i < E[node].size(); i++) {
    int to = E[node][i];
    if (to == d) continue;
    dp[node] = max(dp[node], dp[to]);
  }
  check_ans(node);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  dfs(1);
  if (ans == -(1LL << 60)) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
