#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define len(s) (int)s.length()
#define epb emplace_back
#define fir first
#define sed second
#define sz(ds) (int)ds.size()
#define all(arr) arr.begin(), arr.end()
const int maxn = 1e6 + 5;
int n, m, s, e;
vector<int> adj[maxn], rv_adj[maxn];
int pass[maxn];
ll val[maxn];
vector<int> st;
vector<int> dag[maxn];
vector< vector<int> > comps;
int comp_of[maxn];
ll sum_of[maxn];
ll dp[maxn];
bool contain_e[maxn];
vector<int> ord;
void dfs_1(int u){
pass[u] = true;
for(auto v : adj[u]){
if(!pass[v]) dfs_1(v);
}
ord.epb(u);
}
void dfs_2(int u){
pass[u] = true;
st.epb(u);
for(auto v : rv_adj[u]){
if (!pass[v]) dfs_2(v);
}
}
int main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//
cin >> n >> m >> s >> e;
for (int i = 1 ; i <= n ; i++) cin >> val[i];
for (int i = 0 ; i < m ; i++) {
int u, v;
cin >> u >> v;
adj[u].epb(v);
rv_adj[v].epb(u);
}
for(int i = 1 ; i <= n ;i++){
if(!pass[i])
dfs_1(i);
}
// dfs_1(s)
reverse(ord.begin(),ord.end());
fill(pass,pass+maxn,false);
for(auto i : ord){
if(!pass[i]){
dfs_2(i);
ll tmp = 0;
ll nx_idx = sz(comps);
for (auto v : st) {
if (v == e) contain_e[nx_idx] = true;
tmp += val[v];
comp_of[v] = nx_idx;
}
sum_of[nx_idx] = tmp;
comps.epb(st);
st.clear();
}
}
for (int i = 1 ; i <= n ; i++) {
for (auto v : adj[i]) {
int comp_i = comp_of[i];
int comp_v = comp_of[v];
if (comp_i != comp_v) {
dag[comp_i].epb(comp_v);
}
}
}
fill(pass,pass+maxn,false);
function<void(int,int)> dfs = [&](int u, int p){
pass[u] = true;
ll max_e = 0;
for(auto v : dag[u]){
assert(v != p);
if (!pass[v]){
dfs(v,u);
}
if (contain_e[v]){
max_e = max(max_e,dp[v]);
}
}
if(contain_e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