#include <bits/stdc++.h>
using namespace std;
const long long int M = -1e16 - 18;
const long long int N = 2e5;
long long int power(long long int x, long long int y, long long int M = ::M) {
  x %= M;
  long long int ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % M;
    y >>= 1LL;
    x = (x * x) % M;
  }
  return ans;
}
long long int add(long long int a, long long int b) {
  return ((a % M + b % M) % M);
}
long long int sub(long long int a, long long int b) {
  return ((a % M - b % M + M) % M);
}
long long int mul(long long int a, long long int b) {
  return (((a % M) * (b % M)) % M);
}
long long int divi(long long int a, long long int b) {
  return (mul(a, power(b, M - 2)) % M);
}
vector<int> v[200001];
long long int indp[200001];
long long int dp[200001];
long long int outdp[200001];
long long int arr[200001];
void dfs1(int val, int par) {
  long long int mx = M;
  bool f = 0;
  dp[val] = arr[val];
  for (auto ele : v[val]) {
    if (ele == par) continue;
    dfs1(ele, val);
    f = 1;
    dp[val] += dp[ele];
    mx = max({mx, indp[ele], dp[ele]});
  }
  indp[val] = max({mx, dp[val]});
}
void dfs2(int val, int par) {
  long long int mx1 = M, mx2 = M;
  for (auto ele : v[val]) {
    if (ele == par) continue;
    if (indp[ele] > mx1)
      mx2 = mx1, mx1 = indp[ele];
    else if (indp[ele] > mx2)
      mx2 = indp[ele];
  }
  for (auto ele : v[val]) {
    if (ele == par) continue;
    long long int use = mx1;
    if (indp[ele] == mx1) use = mx2;
    outdp[ele] = max(outdp[val], use);
    dfs2(ele, val);
  }
}
inline void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 0, a, b; i < n - 1; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    indp[i] = M;
    outdp[i] = M;
  }
  dfs1(1, 0);
  dfs2(1, 0);
  long long int sum = M;
  for (int i = 1; i <= n; i++) {
    sum = max(sum, dp[i] + outdp[i]);
  }
  if (sum <= (-3000000000))
    cout << "Impossible";
  else
    cout << sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
