#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> nodes[200001];
int val[200001];
long long anss = -1111111111111;
long long sum[200001];
int in[200001];
pair<long long, long long> maxs[200001];
priority_queue<pair<long long, int>> resss;
long long dfs(int node) {
  if (node == 8) {
    int aa = 0;
  }
  if (in[node]) return 0;
  in[node] = true;
  int ct = 0;
  for (int i = 0; i < nodes[node].size(); i++) {
    if (in[nodes[node][i]]) continue;
    if (in[nodes[node][i]] != 1) ct++;
    long long tmp = dfs(nodes[node][i]);
    long long tmpmax1 = maxs[nodes[node][i]].first;
    long long tmpmax2 = maxs[nodes[node][i]].second;
    if (tmp >= tmpmax1) {
      tmpmax2 = -1111111111111;
      tmpmax1 = tmp;
    }
    long long tmpp[4] = {tmpmax1, tmpmax2, maxs[node].first, maxs[node].second};
    sort(tmpp, tmpp + 4);
    maxs[node].first = tmpp[3];
    maxs[node].second = tmpp[2];
    sum[node] += tmp;
  }
  sum[node] += val[node];
  if (ct > 1) {
    anss = max(anss, (maxs[node].first + maxs[node].second));
  }
  return sum[node];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> val[i];
  }
  for (int i = 1; i <= n; i++) {
    maxs[i].first = maxs[i].second = -1111111111111;
  }
  for (int i = 1; i <= n - 1; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    nodes[tmp2].push_back(tmp1);
    nodes[tmp1].push_back(tmp2);
  }
  dfs(1);
  if (anss == -1111111111111)
    cout << "Impossible" << endl;
  else
    cout << anss << endl;
  return 0;
}
