#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const long long mod = 1000000007ll;
long long a[N], pre[N], nxt[N], in[N], f[N];
int main() {
  long long n, m, s, i, j, x, y;
  scanf("%I64d%I64d%I64d", &n, &m, &s);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &in[i]);
    a[i] = in[i];
  }
  for (i = 1; i <= m; i++) {
    scanf("%I64d%I64d", &x, &y);
    pre[y] = x;
    nxt[x] = y;
  }
  long long cnt = 0;
  for (i = 1; i <= n; i++)
    if (pre[i] == 0) {
      x = i;
      while (x) {
        a[x] += a[pre[x]];
        x = nxt[x];
        cnt++;
      }
    }
  if (cnt < n) {
    printf("0\n");
    return 0;
  }
  for (i = 1; i <= n; i++)
    if (nxt[i] == 0) {
      x = i;
      y = 0;
      while (x) {
        s -= y * in[x];
        if (s < 0) {
          printf("0\n");
          return 0;
        }
        x = pre[x];
        y++;
      }
    }
  f[0] = 1;
  for (i = 1; i <= n; i++)
    for (j = 0; j + a[i] <= s; j++) {
      f[j + a[i]] += f[j];
      f[j + a[i]] %= mod;
    }
  printf("%I64d\n", f[s]);
}
