#include <bits/stdc++.h>
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
using namespace std;
const long long maxn = 2e5 + 10;
long long mx[maxn], val[maxn], sum[maxn];
vector<long long> g[maxn];
long long pass[maxn];
bool ok = 0;
long long ans = LLONG_MIN;
void dfs(long long aa = 1, long long aaa = 0) {
  vector<long long> v;
  sum[aa] = val[aa];
  for (long long a : g[aa]) {
    if (a == aaa) continue;
    dfs(a, aa);
    sum[aa] += sum[a];
    v.push_back(pass[a]);
  }
  if (!v.empty()) {
    sort(v.begin(), v.end());
    pass[aa] = max(v.back(), sum[aa]);
    if (v.size() >= 2) {
      ans = max(ans, v[v.size() - 1] + v[v.size() - 2]);
    }
  } else {
    pass[aa] = sum[aa];
  }
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> val[i];
  for (long long i = 1; i <= n; ++i) mx[i] = LLONG_MIN;
  for (long long i = 1; i < n; ++i) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (long long i = 1; i <= n; ++i) pass[i] = LLONG_MIN;
  dfs(1);
  if (ans == LLONG_MIN)
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
