#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18 + 1l;
const int N = 300300;
long long ans = -INF;
long long a[N];
long long sum[N];
vector<int> g[N];
bool used[N];
void dfs(int v) {
  used[v] = 1;
  sum[v] = a[v];
  a[v] = -INF;
  long long m1 = -INF;
  long long m2 = -INF;
  for (int u : g[v]) {
    if (used[u]) continue;
    dfs(u);
    sum[v] += sum[u];
    long long val = a[u];
    a[v] = max(a[v], val);
    if (m1 < val) swap(m1, val);
    if (m2 < val) swap(m2, val);
  }
  if (m2 > -INF) {
    ans = max(ans, m1 + m2);
  }
  a[v] = max(a[v], sum[v]);
  return;
}
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    for (int i = 0; i < n; i++) {
      in >> a[i];
    }
    for (int i = 1; i < n; i++) {
      int v, u;
      in >> v >> u;
      v--;
      u--;
      g[v].push_back(u);
      g[u].push_back(v);
    }
    dfs(0);
    if (ans == -INF)
      out << "Impossible\n";
    else
      out << ans;
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
