#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a < b) return b;
  return a;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
vector<vector<long long>> v(200005);
long long pleasure[200005], subtree[200005];
long long ans = -((1LL << 60) - 1);
long long sumDfs(long long node, long long par) {
  long long sum = 0;
  for (auto x : v[node]) {
    if (x == par) continue;
    sum += sumDfs(x, node);
  }
  subtree[node] = sum + pleasure[node];
  return subtree[node];
}
long long dfs(long long node, long long par) {
  vector<pair<long long, long long>> child;
  vector<pair<long long, long long>> total;
  for (auto x : v[node]) {
    if (x == par) continue;
    child.push_back({dfs(x, node), x});
    total.push_back({subtree[x], x});
  }
  if (child.empty()) return subtree[node];
  sort(child.rbegin(), child.rend());
  sort(total.rbegin(), total.rend());
  if (child.size() == 1) return max(subtree[node], child[0].first);
  ans = max(
      {ans, child[0].first + child[1].first, total[0].first + total[1].first});
  for (int i = 0; i < total.size(); i++) {
    if (total[i].second == child[0].second) continue;
    ans = max(ans, child[0].first + total[i].first);
    break;
  }
  for (int i = 0; i < child.size(); i++) {
    if (total[0].second == child[i].second) continue;
    ans = max(ans, child[i].first + total[0].first);
    break;
  }
  return max({child[0].first, total[0].first, subtree[node]});
}
void solve() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> pleasure[i];
  for (int i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  sumDfs(1, -1);
  dfs(1, -1);
  if (ans == -((1LL << 60) - 1))
    cout << "Impossible\n";
  else
    cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
