#include <bits/stdc++.h>
const long long maxn = 310;
const long long maxd = 110000;
const long long p = 1000000007;
long long a[maxn], ind[maxn], nxt[maxn], b[maxn], sta[maxn], twp[maxn],
    subs[maxn];
long long dp[maxd];
long long n, q, t, u, v, st, ed, lsta, ltwp;
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (long long i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (long long i = 1; i <= q; i++) {
    scanf("%d%d", &u, &v);
    ind[v]++;
    nxt[u] = v;
  }
  st = ed = lsta = 0;
  for (long long i = 1; i <= n; i++)
    if (!ind[i]) b[++ed] = i, sta[++lsta] = i;
  while (st < ed) {
    long long i = b[++st];
    if (!(--ind[nxt[i]])) b[++ed] = nxt[i];
  }
  if (ed < n) {
    printf("0\n");
    return 0;
  }
  for (long long i = 1; i <= lsta; i++) {
    twp[ltwp = 1] = sta[i];
    while (nxt[twp[ltwp]]) twp[ltwp + 1] = nxt[twp[ltwp]], ltwp++;
    for (long long j = 1; j <= ltwp; j++) subs[j] = a[twp[j]];
    for (long long j = 2; j <= ltwp; j++) subs[j] += subs[j - 1];
    for (long long j = 1; j <= ltwp; j++) a[twp[j]] = subs[j];
    for (long long j = 1; j < ltwp; j++) {
      t -= subs[j];
      if (t < 0) break;
    }
    if (t < 0) break;
  }
  if (t < 0) {
    printf("0\n");
    return 0;
  }
  dp[0] = 1;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= t - a[i]; j++)
      dp[j + a[i]] = (dp[j + a[i]] + dp[j]) % p;
  printf("%d\n", dp[t]);
  return 0;
}
