#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-9;
vector<vector<int> > g;
int q[100100];
bool cmp(const pair<long long, int> &a, const pair<long long, int> &b) {
  return a.first > b.first;
}
pair<long long, int> magicDfs(int v, int p = -1) {
  vector<pair<long long, int> > vect;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) {
      continue;
    }
    vect.push_back(magicDfs(to, v));
  }
  long long am = 0;
  if (p != -1) {
    ++am;
    --q[v];
  }
  sort(vect.begin(), vect.end(), cmp);
  for (int i = 0; i < (int)vect.size(); ++i)
    if (q[v] > 0 && vect[i].first) {
      --q[v];
      am += vect[i].first + 1;
    }
  int add = 0;
  for (int i = 0; i < (int)vect.size(); ++i)
    if (q[v] > 0) {
      int t = min(q[v], vect[i].second);
      add += 2 * t;
      q[v] -= t;
    }
  return make_pair(am + add, q[v]);
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &q[i]);
  }
  g.resize(N);
  for (int i = 0; i + 1 < N; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  int stv;
  scanf("%d", &stv);
  printf("%I64d", magicDfs(stv - 1).first);
  return 0;
}
