#include <bits/stdc++.h>
using namespace std;
const int N = (2e5) + 111;
long long vals[N];
long long dp[2][N];
long long sz[N];
vector<int> g[N];
int n;
bool ok = 0;
long long pre(int v, int p) {
  long long &ans = sz[v];
  ans = vals[v];
  for (int to : g[v])
    if (to != p) {
      ans += pre(to, v);
    }
  return ans;
}
void dfs(int v, int p) {
  dp[0][v] = sz[v];
  vector<long long> opts;
  for (int to : g[v])
    if (to != p) {
      dfs(to, v);
      dp[0][v] = max(dp[0][v], dp[0][to]);
      opts.push_back(dp[0][to]);
    }
  long long a, b = -(1LL << 55);
  if (!opts.empty())
    a = opts[0];
  else
    a = -(1LL << 55);
  for (int i = 1; i < opts.size(); i++) {
    if (opts[i] > a) {
      b = a;
      a = opts[i];
    } else if (opts[i] > b) {
      b = opts[i];
    }
  }
  dp[1][v] = a + b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> vals[i];
  }
  for (int i = 0; i + 1 < n; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  pre(0, -1);
  dfs(0, -1);
  long long ans = *max_element(dp[1], dp[1] + n);
  if (ans > -100000000000000LL)
    cout << ans << '\n';
  else
    cout << "Impossible\n";
  return 0;
}
