#include <bits/stdc++.h>
using namespace std;
int n;
long long pls[1000000];
long long dp[1000000];
long long subsum[1000000];
long long bestsub[1000000];
long long globmax;
long long tempsort[1000000];
vector<int> adjlist[1000000];
void DFS(int node, int parent) {
  subsum[node] = pls[node];
  bestsub[node] = -1e10;
  int len = adjlist[node].size();
  for (int i = 0; i < len; i++) {
    int nx = adjlist[node][i];
    if (nx == parent) continue;
    DFS(nx, node);
    subsum[node] += subsum[nx];
    bestsub[node] = max(bestsub[node], max(bestsub[nx], subsum[nx]));
  }
  bestsub[node] = max(subsum[node], bestsub[node]);
}
void DPTree(int node, int parent) {
  long long cursum = -1e10;
  int len = adjlist[node].size();
  int tempdex = 0;
  for (int i = 0; i < len; i++) {
    int nx = adjlist[node][i];
    if (nx != parent) {
      tempsort[tempdex] = bestsub[nx];
      tempdex++;
    }
  }
  sort(tempsort, tempsort + tempdex);
  if (tempdex > 1) {
    cursum = max(cursum, tempsort[tempdex - 1] + tempsort[tempdex - 2]);
  }
  globmax = max(globmax, cursum);
  for (int i = 0; i < len; i++) {
    int nx = adjlist[node][i];
    if (nx != parent) {
      DPTree(nx, node);
    }
  }
}
int main() {
  cin >> n;
  globmax = -1e10;
  for (int i = 1; i <= n; i++) cin >> pls[i];
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adjlist[a].push_back(b);
    adjlist[b].push_back(a);
  }
  DFS(1, -1);
  DPTree(1, -1);
  if (globmax == -1e10)
    cout << "Impossible" << endl;
  else
    cout << globmax << endl;
  return 0;
}
