#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
const int mod = 1e9 + 7;
int a[N], nxt[N], prv[N], dp[N];
void add(int &u, int v) {
  u += v;
  if (u >= mod) u -= mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  long long t;
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= q; i++) {
    int u, v;
    cin >> u >> v;
    nxt[u] = v;
    prv[v] = u;
  }
  vector<int> v;
  for (int i = 1; i <= n; i++)
    if (prv[i] == 0) v.push_back(i);
  vector<long long> b;
  for (auto u : v) {
    vector<int> cur;
    long long now = u;
    cur.push_back(now);
    while (nxt[now]) {
      now = nxt[now];
      cur.push_back(now);
    }
    now = 0;
    for (int i = 0; i < cur.size(); i++) {
      now += a[cur[i]];
      if (i < cur.size() - 1) t -= now;
      if (t < 0) return puts("0"), 0;
      b.push_back(now);
    }
  }
  dp[0] = 1;
  for (auto u : b) {
    for (int i = 0; i + u < N; i++) {
      add(dp[i + u], dp[i]);
    }
  }
  if (t < 0 || b.size() < n)
    cout << 0 << endl;
  else
    cout << dp[t] << endl;
  return 0;
}
