#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
const int MAXT = 1e5 + 10;
const int MOD = 1e9 + 7;
long long n, q, t, pre[MAXN], nex[MAXN], arr[MAXN];
vector<long long> all;
long long dp[MAXT];
int main() {
  ios::sync_with_stdio(0);
  memset(pre, -1, sizeof(pre));
  memset(nex, -1, sizeof(nex));
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    pre[v] = u;
    nex[u] = v;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!(~pre[i])) {
      vector<long long> local;
      int me = i;
      do {
        cnt++;
        local.push_back(arr[me]);
        me = nex[me];
      } while (~me);
      all.push_back(local[0]);
      for (int j = 1; j < local.size(); j++) {
        local[j] += local[j - 1];
        all.push_back(local[j]);
        t -= local[j];
      }
      t += local.back() - local[0];
    }
  }
  if ((cnt != n) || (t < 0)) return cout << 0 << endl, 0;
  dp[0] = 1;
  for (auto i : all)
    for (int j = i; j <= t; j++) dp[j] = (dp[j] + dp[j - i]) % MOD;
  cout << dp[t] << endl;
  return 0;
}
