#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 200002;
const ll INF = -1999999999999;
ll n, m, u, v, ans = INF, ples[MAX_N], visit[MAX_N], pod[MAX_N], max_pod[MAX_N],
               dp[MAX_N];
vector<vector<int> > G(MAX_N);
bool compare(const int &a, const int &b) { return max_pod[a] < max_pod[b]; }
void licz_poddrzewa(int x, int par) {
  pod[x] = ples[x];
  for (int i = 0; i < G[x].size(); i++) {
    if (G[x][i] != par) {
      licz_poddrzewa(G[x][i], x);
      pod[x] += pod[G[x][i]];
    }
  }
}
void licz_max(int x, int par) {
  max_pod[x] = pod[x];
  for (int i = 0; i < G[x].size(); i++) {
    if (G[x][i] != par) {
      licz_max(G[x][i], x);
      max_pod[x] = max(max_pod[x], max_pod[G[x][i]]);
    }
  }
}
void licz_dp(int x, int par) {
  dp[x] = INF;
  int rozmiar = G[x].size();
  if (rozmiar >= 3 || (x == 1 && rozmiar >= 2)) {
    sort(G[x].begin(), G[x].end(), compare);
    dp[x] = max_pod[G[x][rozmiar - 1]] + max_pod[G[x][rozmiar - 2]];
    if (G[x][rozmiar - 1] == par)
      dp[x] = max_pod[G[x][rozmiar - 2]] + max_pod[G[x][rozmiar - 3]];
    if (G[x][rozmiar - 2] == par)
      dp[x] = max_pod[G[x][rozmiar - 1]] + max_pod[G[x][rozmiar - 3]];
  }
  for (int i = 0; i < rozmiar; i++)
    if (G[x][i] != par) licz_dp(G[x][i], x);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ples[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  licz_poddrzewa(1, 0);
  licz_max(1, 0);
  licz_dp(1, 0);
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  if (ans != INF)
    cout << ans << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}
