#include <bits/stdc++.h>
using namespace std;
const long long N = 200001;
vector<long long> v[N];
long long n, m, s;
long long w[N], vis[N];
void dfs(long long node, long long parent) {
  vis[node] = 1;
  bool is = false;
  for (long long child : v[node]) {
    if (child == parent) continue;
    if (vis[child] == 1) {
      is = true;
    } else if (vis[child] == 0) {
      dfs(child, node);
      if (vis[child] == 1) is = true;
    }
  }
  if (is == false) {
    vis[node] = 2;
  }
}
long long getMax(long long node, long long parent) {
  long long cur = 0;
  for (long long child : v[node]) {
    if (vis[child] == 0) {
      vis[child] = 1;
      cur = max(cur, getMax(child, node));
    }
  }
  return cur + w[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> w[i];
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  cin >> s;
  memset(vis, 0, sizeof(vis));
  dfs(s, -1);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (vis[i] == 1) {
      ans += w[i];
      w[i] = 0;
    }
  }
  memset(vis, 0, sizeof(vis));
  vis[s] = 1;
  long long ex = getMax(s, -1);
  ans += ex;
  cout << ans;
}
