#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
const long long inf = 1e18;
long long value[N], sumSub[N], subMx[N];
vector<long long> adj[N];
long long res;
void dfs(long long node, long long par) {
  long long i = 0;
  for (long long to : adj[node]) {
    if (to == par) {
      adj[node].erase(adj[node].begin() + i);
      break;
    }
    ++i;
  }
  subMx[node] = -inf;
  sumSub[node] = value[node];
  for (long long to : adj[node]) {
    dfs(to, node);
    sumSub[node] += sumSub[to];
    subMx[node] = max(subMx[node], subMx[to]);
  }
  subMx[node] = max(subMx[node], sumSub[node]);
}
void dfs2(long long node, long long mx) {
  vector<long long> prefixMx(adj[node].size(), -inf);
  long long i = 0;
  for (long long to : adj[node]) {
    prefixMx[i] = max(prefixMx[i], subMx[to]);
    if (i) {
      prefixMx[i] = max(prefixMx[i], prefixMx[i - 1]);
    }
    ++i;
  }
  vector<long long> suffixMx(adj[node].size(), -inf);
  for (long long i = (long long)adj[node].size() - 1; i >= 0; --i) {
    const long long to = adj[node][i];
    suffixMx[i] = max(suffixMx[i], subMx[to]);
    if (i + 1 < (long long)adj[node].size()) {
      suffixMx[i] = max(suffixMx[i], suffixMx[i + 1]);
    }
  }
  i = 0;
  for (long long to : adj[node]) {
    long long nextMx = mx;
    if (i) nextMx = max(nextMx, prefixMx[i - 1]);
    if (i + 1 < adj[node].size()) nextMx = max(nextMx, suffixMx[i + 1]);
    res = max(res, subMx[to] + nextMx);
    dfs2(to, nextMx);
    ++i;
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> value[i];
  }
  for (long long i = 1; i < n; ++i) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1);
  res = -inf;
  dfs2(1, -inf);
  if (res < -inf / 2LL) {
    cout << "Impossible\n";
  } else
    cout << res << '\n';
}
