#include <bits/stdc++.h>
using namespace std;
class TreeNode {
 public:
  long long val;
  long long maxiTree;
  long long sumTree;
  long long maxi_two;
  bool exist;
  vector<TreeNode*> child;
};
void construct_tree(int x, TreeNode** root, vector<long long>& a,
                    vector<vector<int> >& g, vector<bool>& vis) {
  vis[x] = true;
  (*root) = new TreeNode();
  (*root)->val = a[x];
  TreeNode* temp;
  int cnt = 0;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (!vis[y]) {
      (*root)->child.push_back(temp);
      construct_tree(y, &((*root)->child[cnt]), a, g, vis);
      cnt++;
    }
  }
}
void calc_sum(TreeNode* root) {
  root->sumTree = 0;
  for (int i = 0; i < root->child.size(); i++) {
    calc_sum(root->child[i]);
    root->sumTree += root->child[i]->sumTree;
  }
  root->sumTree += root->val;
}
void calc_maxi(TreeNode* root) {
  root->maxiTree = root->sumTree;
  for (int i = 0; i < root->child.size(); i++) {
    calc_maxi(root->child[i]);
    root->maxiTree = max(root->maxiTree, root->child[i]->maxiTree);
  }
  root->sumTree += root->val;
}
void calc_maxi_two(TreeNode* root) {
  vector<long long> maxi;
  root->exist = false;
  for (int i = 0; i < root->child.size(); i++) {
    TreeNode* ch = (root->child[i]);
    if (maxi.size() < 2) {
      maxi.push_back(ch->maxiTree);
    } else if (maxi[0] < ch->maxiTree) {
      maxi[0] = ch->maxiTree;
    }
    sort(maxi.begin(), maxi.end());
  }
  if (maxi.size() == 2) {
    root->exist = true;
    root->maxi_two = maxi[0] + maxi[1];
  }
  for (int i = 0; i < root->child.size(); i++) {
    TreeNode* ch = (root->child[i]);
    calc_maxi_two(ch);
    if (ch->exist) {
      if (!root->exist || ch->maxi_two > root->maxi_two) {
        root->exist = true;
        root->maxi_two = ch->maxi_two;
      }
    }
  }
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int> > g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  TreeNode* root;
  vector<bool> vis(n, false);
  construct_tree(0, &root, a, g, vis);
  calc_sum(root);
  calc_maxi(root);
  calc_maxi_two(root);
  if (root->exist)
    cout << root->maxi_two << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}
