#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long INF = 1e15;
vector<vector<int> > g(MAXN, vector<int>());
vector<long long> sums(MAXN, 0);
vector<int> vis(MAXN, 0);
vector<int> was(MAXN, 0);
long long dfs(int u, long long& mx) {
  vis[u] = 1;
  long long v, currmx = -INF, val;
  long long res = 0;
  vector<long long> ans;
  for (int i = 0; i < (int)g[u].size(); i++) {
    v = g[u][i];
    if (!vis[v]) {
      val = dfs(v, mx);
      ans.push_back(val);
      currmx = max(currmx, val);
      res += sums[v];
    }
  }
  res += was[u];
  sums[u] = res;
  currmx = max(currmx, sums[u]);
  int sz = (int)ans.size();
  if (sz >= 2) {
    sort(ans.begin(), ans.end());
    mx = max(mx, ans[sz - 2] + ans[sz - 1]);
  }
  return currmx;
}
int main() {
  int n, u, v;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> was[i];
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long mx = -INF;
  dfs(1, mx);
  if (mx == -INF)
    cout << "Impossible\n";
  else
    cout << mx;
  return 0;
}
