#include <bits/stdc++.h>
using namespace std;
const int MX = 123;
const int MOD = int(360);
const long long oo = LLONG_MAX;
pair<long long, long long> go(vector<vector<int> >& graph, vector<long long>& a,
                              int p, int u, bool& can, long long& ans) {
  long long sum = a[u];
  long long best0 = -oo, best1 = -oo;
  int cnt = 0;
  for (auto& v : graph[u]) {
    if (v != p) {
      cnt++;
      pair<long long, long long> cur = go(graph, a, u, v, can, ans);
      sum += cur.first;
      long long best = max(cur.first, cur.second);
      if (best >= best0) {
        best1 = best0;
        best0 = best;
      } else if (best >= best1) {
        best1 = best;
      }
    }
  }
  if (cnt == 0) {
    return {a[u], a[u]};
  }
  if (best0 != -oo && best1 != -oo) {
    can = true;
    ans = max(ans, best0 + best1);
  }
  return {sum, best0};
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  while (cin >> n) {
    vector<vector<int> > graph(n);
    vector<long long> a(n);
    for (auto& e : a) {
      cin >> e;
    }
    for (int i = 0; i + 1 < n; i++) {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    bool can = false;
    long long ans = -oo;
    go(graph, a, -1, 0, can, ans);
    if (can) {
      cout << ans << "\n";
    } else {
      cout << "Impossible\n";
    }
  }
  return 0;
}
