#include <bits/stdc++.h>
using namespace std;
long long sol[200000];
long long solve(int in, vector<int> v[], int visited[], int a[]) {
  if (sol[in] != -2e16) {
    return sol[in];
  }
  long long ans = a[in];
  visited[in] = 1;
  for (int i = 0; i < v[in].size(); i++) {
    if (visited[v[in][i]] == 0) {
      ans += solve(v[in][i], v, visited, a);
    }
  }
  visited[in] = 0;
  sol[in] = ans;
  return ans;
}
long long max1[200000];
long long maxx(int in, vector<int> v[], int visited[], long long sol[]) {
  if (max1[in] != -2e16) {
    return max1[in];
  }
  long long ans = sol[in];
  visited[in] = 1;
  for (int i = 0; i < v[in].size(); i++) {
    if (visited[v[in][i]] == 0) {
      long long xx = maxx(v[in][i], v, visited, sol);
      if (xx > ans) {
        ans = xx;
      }
    }
  }
  visited[in] = 0;
  max1[in] = ans;
  return ans;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> v[n];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x - 1].push_back(y - 1);
    v[y - 1].push_back(x - 1);
  }
  int vis[n];
  for (int i = 0; i < n; i++) {
    vis[i] = 0;
  }
  for (int i = 0; i < 200000; i++) {
    sol[i] = -2e16;
    max1[i] = -2e16;
  }
  long long xx = solve(0, v, vis, a);
  long long xy = maxx(0, v, vis, sol);
  queue<int> q;
  q.push(0);
  long long ans = -2e16;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    vis[p] = 1;
    priority_queue<long long> pq;
    for (int i = 0; i < v[p].size(); i++) {
      if (vis[v[p][i]] == 0) {
        pq.push(max1[v[p][i]]);
        q.push(v[p][i]);
      }
    }
    if (pq.size() < 2) {
      continue;
    } else {
      long long val = pq.top();
      pq.pop();
      val += pq.top();
      if (val > ans) {
        ans = val;
      }
    }
  }
  if (ans == -2e16) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
