#include <bits/stdc++.h>
using namespace std;
const int maxN = 100500;
const int INF = (int)1e9;
const long long MOD = 7 + (long long)1e9;
const double eps = 1e-9;
int A[maxN];
int next_[maxN];
int mark[maxN];
long long dp[maxN];
int main(void) {
  int n, q, t;
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    next_[i] = -1;
  }
  for (int i = 1; i <= q; i++) {
    int b, c;
    cin >> b >> c;
    next_[b] = c;
    mark[c] = 1;
  }
  vector<int> a;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) continue;
    int s = 0;
    int j = i;
    while (j != -1) {
      t -= s;
      s += A[j];
      a.push_back(s);
      j = next_[j];
      if (t < 0) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  if (t < 0 || a.size() < n) {
    cout << 0 << endl;
    return 0;
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = a[i]; j <= t; j++) {
      dp[j] = (dp[j] + dp[j - a[i]]) % MOD;
    }
  cout << dp[t] << endl;
  return 0;
}
