#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001];
long long sum[200001];
long long mx[200001];
bool vis[200001];
vector<int> conn[200001];
long long computeSum(int i) {
  if (vis[i]) return 0;
  vis[i] = true;
  long long s = a[i];
  for (int j = 0; j < conn[i].size(); j++) {
    if (conn[i][j] == -1) continue;
    if (vis[conn[i][j]])
      conn[i][j] = -1;
    else
      s += computeSum(conn[i][j]);
  }
  return (sum[i] = s);
}
long long computeMax(int i) {
  if (conn[i].size() == 0 || conn[i][0] == -1) return (mx[i] = sum[i]);
  long long ret = computeMax(conn[i][0]);
  for (int j = 1; j < conn[i].size(); j++) {
    if (conn[i][j] != -1) ret = max(ret, computeMax(conn[i][j]));
  }
  if (i != 0) ret = max(ret, sum[i]);
  return (mx[i] = ret);
}
int main() {
  scanf("%d", &n);
  int aa;
  for (int i = 0; i < n; i++) {
    scanf("%d", &aa);
    a[i] = aa;
  }
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    conn[u - 1].push_back(v - 1);
    conn[v - 1].push_back(u - 1);
  }
  memset(vis, 0, sizeof vis);
  computeSum(0);
  for (int i = 0; i < n; i++) sort(conn[i].rbegin(), conn[i].rend());
  computeMax(0);
  long long ret;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    vector<long long> b;
    for (int j = 0; j < conn[i].size(); j++) {
      if (conn[i][j] == -1) continue;
      b.push_back(mx[conn[i][j]]);
    }
    sort(b.rbegin(), b.rend());
    if (b.size() < 2) continue;
    if (!flag) {
      flag = true;
      ret = b[0] + b[1];
    } else
      ret = max(ret, b[0] + b[1]);
  }
  if (flag)
    cout << ret << endl;
  else
    cout << "Impossible" << endl;
}
