#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int N = 2e5 + 10;
int n;
long long a[N], sum[N], mx[N], total = 0, ans = -INF;
vector<int> g[N];
void dfs(int u, int p) {
  long long before = total;
  vector<long long> childs;
  long long mm = -INF;
  for (int i = 0; i < ((int)g[u].size()); ++i) {
    int v = g[u][i];
    if (v != p) {
      dfs(v, u);
      childs.push_back(mx[v]);
      mm = max(mm, mx[v]);
    }
  }
  if (childs.size() > 1) {
    sort(childs.begin(), childs.end());
    long long x = childs[((int)childs.size()) - 1],
              y = childs[((int)childs.size()) - 2];
    ans = max(ans, x + y);
  }
  total += a[u];
  sum[u] = total - before;
  mm = max(mm, sum[u]);
  mx[u] = mm;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; ++i) cin >> a[i];
  int u, v;
  for (int i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  if (ans == -INF)
    cout << "Impossible\n";
  else
    cout << ans << endl;
  return 0;
}
