#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> dp[100100];
vector<pair<long long, long long> > children[100100];
vector<long long> edge[100100];
long long n, k[100100], u, v, st;
void addedge(long long u, long long v) { edge[v].push_back(u); }
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first > b.first;
}
void dfs(long long p, long long fa) {
  dp[p] = make_pair(0, k[p]);
  if (p == st) dp[p].second++;
  for (long long i = 0; i < edge[p].size(); i++) {
    long long u = edge[p][i];
    if (u != fa) dfs(u, p);
  }
}
void solve(long long k, long long fa) {
  for (long long i = 0; i < edge[k].size(); i++) {
    long long u = edge[k][i];
    if (u != fa) {
      solve(u, k);
      children[k].push_back(dp[u]);
    }
  }
  if (dp[k].second) {
    dp[k].second--;
    dp[k].first++;
  }
  sort(children[k].begin(), children[k].end(), cmp);
  for (long long i = 0; i < children[k].size() && dp[k].second; i++) {
    dp[k].first += children[k][i].first + 1;
    dp[k].second--;
  }
  for (long long i = 0; i < children[k].size() && dp[k].second; i++) {
    long long eaten = min(dp[k].second, children[k][i].second);
    dp[k].second -= eaten;
    dp[k].first += 2 * eaten;
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &k[i]);
  }
  for (int i = 1; i < n; i++) {
    scanf("%lld %lld", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  scanf("%lld", &st);
  dfs(st, -1);
  solve(st, -1);
  dp[st].first--;
  printf("%lld\n", dp[st].first);
  return 0;
}
