#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f[200009], i, j, zx, xc, s, lf[200009], rg[200009],
    tim, up[200009];
vector<long long> v[200009], shv[200009];
pair<long long, long long> dp[200009];
bool bo[200009], ka[200009];
bool anc(long long q, long long w) {
  if (lf[q] <= lf[w] && rg[q] >= rg[w])
    return 1;
  else
    return 0;
}
void dfs(long long q, long long w) {
  bo[q] = 1;
  tim++;
  lf[q] = rg[q] = tim;
  for (vector<long long>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if (bo[(*it)] == 1 && (*it) != w) {
      ka[q] = 1;
    }
    if (bo[(*it)] == 1) continue;
    shv[q].push_back((*it));
    dfs((*it), q);
    if (rg[q] < rg[(*it)]) rg[q] = rg[(*it)];
    if (ka[(*it)] == 1) ka[q] = 1;
  }
}
void dfs2(long long q, long long w) {
  up[q] = q;
  for (vector<long long>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if ((*it) == w) continue;
    if (anc((*it), up[q]) == 1) up[q] = (*it);
  }
  for (vector<long long>::iterator it = shv[q].begin(); it != shv[q].end();
       it++) {
    dfs2((*it), w);
    if (anc(up[(*it)], up[q]) == 1) up[q] = up[(*it)];
  }
}
void dfs3(long long q, long long w) {
  dp[q].first = 0;
  dp[q].second = 0;
  long long pas = 0, mx = 0, mxx = 0, ma = 0;
  for (vector<long long>::iterator it = shv[q].begin(); it != shv[q].end();
       it++) {
    dfs3((*it), q);
    pas += dp[(*it)].first;
    if (mxx < dp[(*it)].second) mxx = dp[(*it)].second;
    if (ma < dp[(*it)].second - dp[(*it)].first)
      ma = dp[(*it)].second - dp[(*it)].first;
  }
  if (ka[q] == 1) {
    dp[q].first = pas + f[q];
  }
  dp[q].second = pas + f[q] + ma;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  for (i = 1; i <= a; i++) cin >> f[i];
  for (i = 1; i <= b; i++) {
    cin >> c >> d;
    v[c].push_back(d);
    v[d].push_back(c);
  }
  cin >> s;
  dfs(s, 0);
  dfs2(s, 0);
  dfs3(s, 0);
  cout << dp[s].second;
  return 0;
}
