#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, a[200005];
vector<long long> adj[200005];
long long ans;
bool Impossible;
long long val[200005], Val[200005];
void dfs(long long u, long long par) {
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (v == par) continue;
    dfs(v, u);
  }
  val[u] = a[u];
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (v == par) continue;
    val[u] += Val[v];
  }
  Val[u] = val[u];
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (v == par) continue;
    val[u] = max(val[u], val[v]);
  }
  if (adj[u].size() <= 1) return;
  if (u != 1 && adj[u].size() == 2) return;
  Impossible = false;
  long long a = 0;
  if (adj[u][a] == par) a++;
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (v == par) continue;
    if (val[v] >= val[adj[u][a]]) a = i;
  }
  long long b = 0;
  while (adj[u][b] == par || b == a) b++;
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (v == par || a == i) continue;
    if (val[v] >= val[adj[u][b]]) b = i;
  }
  a = val[adj[u][a]];
  b = val[adj[u][b]];
  ans = max(ans, a + b);
  return;
}
void solve() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  Impossible = true;
  ans = -1e16;
  dfs(1, 0);
  if (Impossible)
    printf("Impossible");
  else
    printf("%lld", ans);
  return;
}
int main() {
  long long T = 1;
  for (long long i = 1; i <= T; i++) {
    solve();
  }
  return 0;
}
