#include <bits/stdc++.h>
using namespace std;
const long long int INF = 98769876987698889LL;
const int MOD = 1e9 + 7;
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx4[] = {1, -1, 0, 0};
const int dy4[] = {0, 0, 1, -1};
const int N = 2e5 + 5;
long long int dp1[N], a[N], f[N], dp2[N], s[N];
int n;
vector<int> G[N];
void dfs(int x, int pa) {
  if (G[x].size() == 1 and G[x][0] == pa) {
    s[x] = a[x];
    return;
  }
  s[x] = a[x];
  for (auto k : G[x]) {
    if (k == pa) continue;
    dfs(k, x);
    s[x] += s[k];
  }
}
void dfs2(int x, int pa) {
  if (G[x].size() == 1 and G[x][0] == pa) {
    f[x] = 0;
    return;
  }
  f[x] = 0;
  vector<long long int> v;
  for (auto k : G[x]) {
    if (k == pa) continue;
    dfs2(k, x);
    if (s[k] >= dp1[k]) {
      v.push_back(s[k]);
    } else {
      v.push_back(dp1[k]);
    }
  }
  sort(v.begin(), v.end());
  dp1[x] = v[v.size() - 1];
  if (v.size() > 1) {
    f[x] = 1;
    dp2[x] = v[v.size() - 2];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < N; i++) {
    dp1[i] = -INF;
    dp2[i] = -INF;
  }
  for (int i = 2; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if (n == 1) {
    cout << "Impossible" << endl;
    return 0;
  }
  dfs(1, 0);
  dfs2(1, 0);
  int fl = 0;
  for (int i = 1; i <= n; i++) {
    if (f[i]) fl = 1;
  }
  if (!fl) {
    cout << "Impossible" << endl;
    return 0;
  }
  long long int ans = -INF;
  for (int i = 1; i <= n; i++) {
    if (f[i]) {
      ans = max(ans, dp1[i] + dp2[i]);
    }
  }
  cout << ans;
}
