#include <bits/stdc++.h>
using namespace std;
long long n, q, t;
long long a[200200], b[200200], c[200200], f[200200] = {1};
int link[200200], din[200200], dou[200200];
int main() {
  scanf("%I64d%I64d%I64d", &n, &q, &t);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", a + i);
  }
  memset(link, 0xff, sizeof(link));
  for (int i = 0; i < q; i++) {
    scanf("%I64d%I64d", b + i, c + i);
    link[--b[i]] = --c[i];
    din[c[i]] = 1;
  }
  for (int i = 0; i < n; i++)
    if (!din[i]) {
      int u = i, v;
      while ((v = link[u]) >= 0) {
        link[u] = -1;
        a[v] += a[u];
        if (a[v] > t && link[v] != 1) return puts("0"), 0;
        u = v;
      }
      dou[u] = 1;
    }
  for (int i = 0; i < n; i++)
    if (link[i] != -1) return puts("0"), 0;
  for (int i = 0, j; i < n; i++) {
    if (dou[i])
      for (j = a[i]; j <= t; j++) f[j] += f[j - a[i]], f[j] %= 1000000007;
    else {
      for (j = t; j >= a[i]; j--) f[j] = f[j - a[i]];
      for (j = 0; j < a[i]; j++) f[j] = 0;
      for (j = a[i]; j <= t; j++) f[j] += f[j - a[i]], f[j] %= 1000000007;
    }
  }
  printf("%I64d\n", f[t]);
  return 0;
}
