#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int K = 1e5 + 10;
const int k = 310;
int dp[K], in[k], s[k], a[k];
int main() {
  int n, q, t, u, v;
  scanf("%d %d %d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(in, 0, sizeof(in));
  memset(s, 0, sizeof(s));
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &u, &v);
    in[v]++, s[u] = v;
  }
  while (q--) {
    int p = 0;
    for (int i = 1; i <= n; i++)
      if (!in[i] && s[i]) {
        p = i;
        break;
      }
    if (!p) {
      puts("0");
      return 0;
    }
    t -= a[p];
    if (t < 0) {
      puts("0");
      return 0;
    }
    int ms = s[p];
    s[p] = 0;
    in[ms]--;
    a[ms] += a[p];
  }
  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]]) % mod;
  printf("%d\n", dp[t]);
  return 0;
}
