#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const long long inf = 1e12;
vector<int> adj[N];
long long val[N];
long long t[N];
long long max_d[N];
long long ans = -inf;
void dfs(int u, int parent) {
  t[u] += val[u];
  for (auto v : adj[u]) {
    if (v != parent) {
      dfs(v, u);
      t[u] += t[v];
      if (max_d[u] != -inf) ans = max(ans, max_d[u] + max_d[v]);
      max_d[u] = max(max_d[u], max_d[v]);
    }
  }
  max_d[u] = max(max_d[u], t[u]);
}
int main() {
  int n, v;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
  }
  int a, b;
  for (int i = 1; i <= n - 1; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  fill_n(max_d, N, -inf);
  dfs(1, 0);
  if (ans != -inf)
    cout << ans << "\n";
  else
    cout << "Impossible"
         << "\n";
  return 0;
}
