#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e15;
const long long int mod = 1000000007;
const int infInt = 1e9;
const double PI = acos(-1.00);
const double eps = 1e-6;
long long int weight[200010];
long long int dp[200010];
vector<vector<int> > adj;
vector<vector<int> > level;
int vis[200010];
int levelMax;
void dfs(int u, int lev) {
  vis[u] = true;
  levelMax = max(levelMax, lev);
  level[lev].push_back(u);
  if (adj[u].size() == 0) {
    dp[u] = weight[u];
    return;
  }
  dp[u] = -2LL * inf;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (vis[v] == false) {
      dfs(v, lev + 1);
      weight[u] += weight[v];
      dp[u] = max(dp[u], dp[v]);
    }
  }
  dp[u] = max(dp[u], weight[u]);
}
long long int maxi = -2LL * inf;
bool solve() {
  bool possible = false;
  for (int i = 1; i <= levelMax; i++) {
    int len = level[i].size();
    if (len <= 1) continue;
    possible = true;
    vector<long long int> maxis;
    for (int j = 0; j < len; j++) {
      long long int maximo = dp[level[i][j]];
      maxis.push_back(maximo);
    }
    sort(maxis.begin(), maxis.end());
    maxi = max(maxi, maxis[len - 1] + maxis[len - 2]);
  }
  return possible;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  adj.assign(n + 1, vector<int>());
  level.assign(n + 1, vector<int>());
  for (int i = 1; i <= n; i++) {
    cin >> weight[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  if (solve()) {
    cout << maxi << "\n";
  } else {
    cout << "Impossible"
         << "\n";
  }
}
