#include <bits/stdc++.h>
const int N = 1e5 + 5, P = 1e9 + 7;
int n, q, cnt;
long long t;
struct node {
  int a, ind;
  node *next;
  void calc() {
    cnt++;
    if (!next) return;
    next->calc();
    a += next->a;
    t -= next->a;
  }
} V[N];
int f[N];
int main() {
  scanf("%d%d%I64d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &V[i].a);
  for (int i = 0; i < q; i++) {
    int b, c;
    scanf("%d%d", &b, &c);
    V[c].next = V + b;
    V[b].ind++;
  }
  for (int i = 1; i <= n; i++)
    if (!V[i].ind) V[i].calc();
  if (cnt < n || t < 0) {
    puts("0");
    return 0;
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = V[i].a; j <= t; j++) f[j] = (f[j] + f[j - V[i].a]) % P;
  }
  printf("%d\n", f[t]);
  scanf("\n");
}
