#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<long long> dp;
vector<pair<long long, long long>> ans;
vector<bool> used;
vector<long long> cost;
int n;
void dfs(int v) {
  used[v] = true;
  vector<long long> sons;
  sons.push_back(-1e18);
  sons.push_back(-1e18);
  for (int i = 0; i < g[v].size(); i++) {
    if (!used[g[v][i]]) {
      dfs(g[v][i]);
      dp[v] += dp[g[v][i]];
      if (dp[g[v][i]] > ans[g[v][i]].first || ans[g[v][i]].first == -1e18)
        sons.push_back(dp[g[v][i]]);
      else {
        sons.push_back(ans[g[v][i]].first);
        sons.push_back(ans[g[v][i]].second);
      }
    }
  }
  sort(sons.rbegin(), sons.rend());
  ans[v].first = sons[0];
  ans[v].second = sons[1];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  if (n == 1) {
    cout << "Impossible";
    return 0;
  }
  g.resize(n);
  dp.resize(n);
  ans.resize(n);
  used.resize(n);
  cost.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> dp[i];
    cost[i] = dp[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(0);
  long long mp = -1e18;
  for (int i = 0; i < n; i++) {
    mp = max(mp, ans[i].first + ans[i].second);
  }
  if (mp < -1e15) {
    cout << "Impossible";
  } else {
    cout << mp;
  }
}
