#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > matMul(vector<vector<long long int> > A,
                                      vector<vector<long long int> > B,
                                      long long int m) {
  int r1 = A.size(), r2 = B.size(), c1 = A[0].size(), c2 = B[0].size();
  vector<vector<long long int> > ans(r1);
  for (int i = 0; i < r1; i++)
    for (int j = 0; j < c2; j++) {
      long long int mul = 0;
      for (int k = 0; k < c1; k++) mul = (mul + A[i][k] * B[k][j]) % m;
      ans[i].push_back(mul);
    }
  return ans;
}
vector<vector<long long int> > matPow(vector<vector<long long int> > first,
                                      long long int n, long long int m) {
  int r = first.size(), c = first[0].size();
  vector<vector<long long int> > result(r);
  for (int i = int(0); i < int(r); i++)
    for (int j = int(0); j < int(c); j++) {
      if (i == j)
        result[i].push_back(1);
      else
        result[i].push_back(0);
    }
  while (n > 0) {
    if (n % 2 == 1) result = matMul(result, first, m);
    first = matMul(first, first, m);
    n = n / 2;
  }
  return result;
}
long long int mod = 1e9 + 7;
long long int pow1(long long int first, long long int n, long long int m) {
  long long int result = 1;
  while (n > 0) {
    first %= m;
    if (n % 2 == 1) result = (result * first) % m;
    first = (first * first) % m;
    n = n / 2;
  }
  return result;
}
long long int pow2(long long int first, long long int n) {
  long long int result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * first);
    first = (first * first);
    n = n / 2;
  }
  return result;
}
long long int modInverse(long long int A, long long int M) {
  return pow1(A, M - 2, M);
}
long long int f[1000001];
void fact() {
  f[0] = f[1] = 1;
  for (int i = 2; i <= 1e6; i++) f[i] = (f[i - 1] * i) % mod;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
const int size = 1e6 + 1;
long long int dp[size][2], n, a[size], ans = 1ll * 2 * INT_MIN;
vector<int> Adj[size];
void dfs(int s, int par) {
  long long int c = 0, ma = 1ll * 2 * INT_MIN;
  for (int i = 0; i < Adj[s].size(); i++) {
    int z = Adj[s][i];
    if (z == par) continue;
    dfs(z, s);
    c += dp[z][0];
    ma = max(ma, dp[z][1]);
  }
  dp[s][0] = c + a[s - 1];
  dp[s][1] = max(dp[s][0], ma);
}
void dfs1(int s, int par) {
  vector<long long int> v;
  for (int i = 0; i < Adj[s].size(); i++) {
    int z = Adj[s][i];
    if (z == par) continue;
    dfs1(z, s);
    v.push_back(dp[z][1]);
  }
  if (v.size() >= 2) {
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ans = max(ans, v[0] + v[1]);
  }
}
int main() {
  cin >> n;
  for (int i = int(0); i < int(n); i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    Adj[u].push_back(v);
    Adj[v].push_back(u);
  }
  dfs(1, -1);
  dfs1(1, -1);
  if (ans > 2ll * INT_MIN)
    cout << ans;
  else
    cout << "Impossible";
  return 0;
}
