#include <bits/stdc++.h>
using namespace std;
long long maxx(long long a, long long b) { return (a < b) ? b : a; }
vector<vector<long long> > graph(200010);
vector<long long> pls(200010);
vector<long long> pls_tree(200010);
vector<bool> visited(200010, false);
vector<pair<bool, long long> > max1(200010, make_pair(false, -1e18));
vector<pair<bool, long long> > maxsum(200010, make_pair(false, -1e18));
void dfs(long long idx) {
  long long tmp, test, max_1 = -1e18, max_2 = -1e18, max_sum = -1e18;
  for (int i = 0; i < graph[idx].size(); i++) {
    tmp = graph[idx][i];
    if (!visited[tmp]) {
      visited[tmp] = true;
      dfs(tmp);
      pls_tree[idx] += pls_tree[tmp];
      if (max1[tmp].first == true)
        test = maxx(max1[tmp].second, pls_tree[tmp]);
      else
        test = pls_tree[tmp];
      if (test > max_1) {
        max_2 = max_1;
        max_1 = test;
      } else if (test > max_2)
        max_2 = test;
      if (maxsum[tmp].first == true && max_sum < maxsum[tmp].second)
        max_sum = maxsum[tmp].second;
    }
  }
  if (max_1 != -1e18 && max_2 != -1e18) max_sum = maxx(max_1 + max_2, max_sum);
  if (max_1 != -1e18) {
    max1[idx].first = true;
    max1[idx].second = max_1;
  }
  if (max_sum != -1e18) {
    maxsum[idx].first = true;
    maxsum[idx].second = max_sum;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, u, v;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> pls[i];
    pls_tree[i] = pls[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  visited[1] = true;
  dfs(1);
  if (maxsum[1].first == true)
    cout << maxsum[1].second;
  else
    cout << "Impossible";
  return 0;
}
