#include <bits/stdc++.h>
using namespace std;
const long long N = 200003;
long long inf = -10e17 + 3;
vector<long long> v[N];
long long sum[N], msum[N], val[N], ans = inf;
void dfs(long long ver, long long par) {
  msum[ver] = inf;
  for (auto it : v[ver]) {
    if (it == par) continue;
    dfs(it, ver);
    if (msum[it] != inf && msum[ver] != inf)
      ans = max(ans, msum[it] + msum[ver]);
    sum[ver] += sum[it];
    msum[ver] = max(msum[ver], msum[it]);
  }
  sum[ver] += val[ver];
  msum[ver] = max(msum[ver], sum[ver]);
}
int main() {
  std::ios::sync_with_stdio(false);
  long long n, x, y;
  cin >> n;
  for (int i = int(1); i <= int(n); i++) cin >> val[i];
  for (int i = int(1); i <= int(n - 1); i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  if (ans == inf)
    cout << "Impossible";
  else
    cout << ans;
}
