#include <bits/stdc++.h>
using namespace std;
long long v[200005];
vector<int> child[200005];
vector<int> edge[200005];
int parent[200005];
void make_tree(int idx) {
  int other;
  for (int i = 0; i < edge[idx].size(); i++) {
    other = edge[idx][i];
    if (parent[other] == -1) {
      parent[other] = idx;
      child[idx].push_back(other);
      make_tree(other);
    }
  }
}
long long ans = -2e18;
pair<long long, long long> f(int idx) {
  if (child[idx].size() == 0) return pair<long long, long long>(v[idx], v[idx]);
  if (child[idx].size() == 1) {
    pair<long long, long long> temp = f(child[idx][0]);
    return pair<long long, long long>(temp.first + v[idx],
                                      max(temp.first + v[idx], temp.second));
  }
  long long a, b;
  a = b = -2e18;
  pair<long long, long long> temp;
  long long sum = v[idx];
  for (int i = 0; i < child[idx].size(); i++) {
    temp = f(child[idx][i]);
    sum += temp.first;
    if (temp.second >= a) {
      b = a;
      a = temp.second;
    } else if (temp.second > b) {
      b = temp.second;
    }
  }
  ans = max(ans, a + b);
  return pair<long long, long long>(sum, max(sum, max(a, b)));
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  memset(parent, -1, sizeof parent);
  parent[1] = 1;
  make_tree(1);
  f(1);
  if (ans == -2e18)
    cout << "Impossible\n";
  else
    cout << ans << endl;
  return 0;
}
