#include <bits/stdc++.h>
using namespace std;
long long n, q, t;
const long long N = 305;
const long long T = 1e5 + 100;
const long long mod = 1e9 + 7;
long long a[N];
long long nxt[N];
long long ru[N];
long long b[T];
bool used[N];
signed main() {
  cin >> n >> q >> t;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= q; i++) {
    long long b, c;
    cin >> b >> c;
    nxt[b] = c, ru[c]++;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = nxt[i]; j; j = nxt[j])
      if (j == i) {
        cout << 0 << endl;
        return 0;
      }
  }
  for (long long i = 1; i <= n; i++)
    if (!ru[i]) {
      for (long long j = i; j; j = nxt[j]) {
        a[nxt[j]] += a[j];
      }
    }
  for (long long i = 1; i <= n; i++)
    if (nxt[i]) t -= a[i];
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  b[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = a[i]; j <= t; j++) {
      b[j] = (b[j] + b[j - a[i]]) % mod;
    }
  }
  cout << b[t] << endl;
  return 0;
}
