#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> k;
vector<vector<int> > es;
vector<bool> was;
long long dfs(int v) {
  was[v] = true;
  vector<pair<long long, int> > chi;
  for (int i = 0; i < es[v].size(); i++) {
    int b = es[v][i];
    if (!was[b]) {
      was[b] = true;
      chi.push_back(make_pair(dfs(b), b));
    }
  }
  sort(chi.begin(), chi.end());
  reverse(chi.begin(), chi.end());
  long long ans = 1;
  k[v]--;
  for (int i = 0; i < chi.size() && k[v]; i++) {
    ans += chi[i].first + 1;
    k[v]--;
  }
  for (int i = 0; i < chi.size() && k[v]; i++) {
    int b = chi[i].second;
    long long cnt = min(k[b], k[v]);
    ans += 2 * cnt;
    k[b] -= cnt;
    k[v] -= cnt;
  }
  return ans;
}
int main() {
  while (scanf("%d", &n) >= 1) {
    k = vector<long long>(n);
    for (int i = 0; i < n; i++) scanf("%I64d", &k[i]);
    es = vector<vector<int> >(n);
    for (int i = 1; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b), a--, b--;
      es[a].push_back(b);
      es[b].push_back(a);
    }
    int st;
    scanf("%d", &st), st--;
    k[st]++;
    was = vector<bool>(n, false);
    long long ans = dfs(st) - 1;
    printf("%I64d\n", ans);
    break;
  }
  return 0;
}
