#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int n, q, t, cs, tn, a[maxn], b[maxn], c[maxn], e[maxn], f[maxn], use[maxn],
    dp[maxn], bak[maxn];
int main() {
  scanf("%d %d %d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), bak[i] = a[i];
  memset(e, 0, sizeof(e));
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &b[i], &c[i]);
    e[b[i]] = c[i];
    f[c[i]] = b[i];
  }
  for (int i = 1; i <= n; i++) {
    memset(use, 0, sizeof(use));
    cs = i;
    while (cs != 0) {
      use[cs] = 1;
      cs = e[cs];
      if (use[cs] == 1) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  memset(use, 0, sizeof(use));
  for (int i = 1; i <= n; i++)
    if ((use[i] == 0) && (e[i] != 0) && (f[i] == 0)) {
      cs = i;
      use[i] = i;
      tn = a[i];
      while (e[cs] != 0) {
        cs = e[cs];
        use[cs] = i;
        tn += a[cs];
        a[cs] = tn;
      }
      cs = i;
      while (e[cs] != 0) cs = e[cs];
      tn = 0;
      while (f[cs] != 0) {
        cs = f[cs];
        ++tn;
        t -= tn * bak[cs];
        if (t < 0) {
          cout << 0 << endl;
          return 0;
        }
      }
    }
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = a[i]; j <= t; j++) dp[j] = (dp[j] + dp[j - a[i]]) % 1000000007;
  printf("%d\n", dp[t]);
  return 0;
}
