#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897923846;
const long long int MOD = 1000000007;
const long long int N = 998244353;
long long int power(long long int x, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
long long int modinverse(long long int a) { return power(a, MOD - 2); }
long long int n;
vector<long long int> a;
vector<vector<long long int> > adj;
vector<long long int> sz, mxm;
long long int ans = -(long long int)1e18;
long long int dfs(long long int node, long long int parent) {
  sz[node] = a[node];
  for (auto x : adj[node]) {
    if (x == parent) continue;
    sz[node] += dfs(x, node);
  }
  return sz[node];
}
long long int sfd(long long int node, long long int parent) {
  long long int mnm = sz[node];
  for (auto x : adj[node]) {
    if (x == parent) continue;
    mnm = max(mnm, sfd(x, node));
  }
  return mxm[node] = mnm;
}
void ddfs(long long int node, long long int parent) {
  vector<long long int> count;
  for (auto x : adj[node]) {
    if (x == parent) continue;
    count.push_back(mxm[x]);
    ddfs(x, node);
  }
  sort(count.begin(), count.end());
  reverse(count.begin(), count.end());
  if (count.size() >= 2) {
    ans = max(ans, count[0] + count[1]);
  }
}
void solve() {
  cin >> n;
  sz.resize(n);
  a.resize(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  adj.resize(n);
  for (long long int i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  sz.resize(n, 0);
  dfs(0, -1);
  mxm.resize(n, -(long long int)1e18);
  sfd(0, -1);
  ddfs(0, -1);
  if (ans == -(long long int)1e18)
    cout << "Impossible\n";
  else
    cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int test = 1;
  while (test--) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
