#include <bits/stdc++.h>
inline long long MAX2(long long a, long long int b) {
  return (a) > (b) ? (a) : (b);
}
inline long long MAX3(long long a, long long b, long long c) {
  return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));
}
inline long long MIN2(long long a, long long b) {
  return (a) < (b) ? (a) : (b);
}
inline long long MIN3(long long a, long long b, long long c) {
  return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));
}
using namespace std;
long long a[200005];
vector<vector<int> > graph(200005);
vector<pair<long long, long long> > p(200005);
int vis[200005];
void dfs(int i) {
  vis[i] = 1;
  int j, si = graph[i].size();
  p[i].first = a[i];
  for (j = 0; j < si; j++) {
    int v = graph[i][j];
    if (vis[v]) continue;
    dfs(v);
    p[i].first += p[v].first;
    p[i].second = MAX2(p[i].second, p[v].second);
  }
  p[i].second = MAX2(p[i].first, p[i].second);
}
long long dfs2(int i) {
  vis[i] = 1;
  int j, si = graph[i].size();
  if (i == 0 && si >= 2 || si > 2) {
    long long ans = -1e17;
    long long cur = 0;
    multiset<long long, greater<long long> > s;
    multiset<long long, greater<long long> >::iterator it;
    for (j = 0; j < si; j++) {
      int v = graph[i][j];
      if (vis[v]) continue;
      ans = MAX2(ans, dfs2(v));
      s.insert(p[v].second);
    }
    it = s.begin();
    cur += (*it);
    it++;
    cur += (*it);
    ans = MAX2(ans, cur);
    return ans;
  }
  for (j = 0; j < si; j++) {
    int v = graph[i][j];
    if (vis[v]) continue;
    return dfs2(v);
  }
  return -1e17;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    p[i] = pair<long long, long long>(-1e17 - 1, -1e17 - 1);
  }
  for (i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  for (i = 0; i < n; i++) {
    if (graph[i].size() > 2 || (i == 0 && graph[i].size() >= 2)) break;
  }
  if (i == n) {
    cout << "Impossible";
  } else {
    memset(vis, 0, sizeof vis);
    dfs(0);
    memset(vis, 0, sizeof vis);
    cout << dfs2(0);
  }
  cerr << '\n'
       << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
}
