#include<bits/stdc++.h>
#define mxn 500005
using namespace std;
vector<int> G[mxn], NG[mxn], SCC[mxn], IG[mxn];
int low[mxn], dfn[mxn], vl[mxn], ins[mxn], col[mxn], in[mxn], zh[mxn];
bool cp[mxn];
int n, m, k, cnt, js;
stack<int> S;
priority_queue<int> Q;
priority_queue<int, vector<int>, greater<int> > tmpQ;
void tarjan(int u){
low[u] = dfn[u] = ++cnt;
S.push(u);
ins[u] = 1;
for (auto v :G[u]){
if (!dfn[v]){
tarjan(v);
low[u] = min(low[u], low[v]);
}else if (ins[v])
low[u] = min(low[u], dfn[v]);
}
if (dfn[u] == low[u]){
js++;
while (!S.empty()){
int v = S.top();
S.pop();
SCC[js].push_back(v);
col[v] = js;
ins[v] = 0;
if (u == v)
break;
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
cin >> vl[i];
for (int i = 1; i <= m; i++){
int u, v;
cin >> u >> v;
G[u].push_back(v);
IG[v].push_back(u);
}
for (int i = 1; i <= n; i++)
if (!dfn[i])
tarjan(i);
for (int i = 1; i <= n; i++)
for (auto v : G[i]){
if (col[i] == col[v]){
if (!cp[col[i]])
for (auto w : IG[i])
if (col[w] != col[i]){
in[col[i]] = 1;
cp[col[i]] = 1;
break;
}
continue;
}
NG[col[i]].push_back(col[v]);
in[col[v]]++;
}
for (int i = 1; i <= js; i++){
if (!in[i]){
while (!tmpQ.empty())
tmpQ.pop();
for (auto v : SCC[i])
tmpQ.push(vl[v]);
tmpQ.pop();
while (!tmpQ.empty()){
Q.push(tmpQ.top());
tmpQ.pop();
}
}else{
for (auto v : SCC[i])
Q.push(vl[v]);
}
}
long long ans = 0;
for (int i = 1; i <= k; i++){
if (Q.empty())
break;
ans += Q.top();
Q.pop();
}
cout << ans;
}