#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, nxt;
} e[1111111];
long long m = 0, head[111111];
void conn(long long first, long long second) {
  e[m].to = second;
  e[m].nxt = head[first];
  head[first] = m++;
}
long long n, a[111111], sta, b[111111];
long long cnt[111111];
bool v[111111];
long long opt[111111];
void calc(long long cur) {
  v[cur] = 1;
  long long ret = 1, ret2 = 0;
  vector<long long> first;
  first.clear();
  for (long long i = head[cur]; i != -1; i = e[i].nxt)
    if (!v[e[i].to]) {
      calc(e[i].to);
      first.push_back(opt[e[i].to]);
      ret2 += b[e[i].to];
    }
  sort(first.begin(), first.end());
  reverse(first.begin(), first.end());
  for (long long i = 0; i < min(a[cur] - 1, cnt[cur] - 1); i++)
    ret += first[i] + 1;
  ret2 = min(ret2, b[cur]);
  b[cur] -= ret2;
  ret += ret2 * 2;
  opt[cur] = ret;
}
int main() {
  scanf("%I64d", &n);
  for (long long i = 0; i < n; i++) scanf("%I64d", &a[i]);
  memset(head, -1, sizeof(head));
  memset(cnt, 0, sizeof(cnt));
  for (long long i = 0; i < n - 1; i++) {
    long long first, second;
    scanf("%I64d%I64d", &first, &second);
    --first;
    --second;
    conn(first, second);
    conn(second, first);
    cnt[first]++;
    cnt[second]++;
  }
  for (long long i = 0; i < n; i++) b[i] = max(0ll, a[i] - cnt[i]);
  scanf("%I64d", &sta);
  --sta;
  memset(v, 0, sizeof(v));
  a[sta]++;
  cnt[sta]++;
  calc(sta);
  cout << opt[sta] - 1ll << endl;
  return 0;
}
