#include <bits/stdc++.h>
using std::sort;
int N, M, T, v[305], forw[305], back[305], DP[110000];
void add(int &A, int B) {
  A += B;
  if (A >= 1000000007) A -= 1000000007;
}
int main() {
  int i, j, k, vi = 0, least = 0;
  scanf("%d%d%d", &N, &M, &T);
  for (i = 1; i <= N; i++) scanf("%d", v + i);
  while (M--) {
    scanf("%d%d", &i, &j);
    forw[i] = j;
    back[j] = i;
  }
  for (i = 1; i <= N; i++)
    if (back[i] == 0) {
      int chain = 0;
      for (j = i; j; j = forw[j]) {
        vi++;
        least += chain;
        if (least >= 1000000007) least = 1000000007;
        chain += v[j];
        if (back[j]) v[j] += v[back[j]];
      }
    }
  if (least > T || vi < N) {
    puts("0");
    return 0;
  }
  DP[least] = 1;
  for (i = 1; i <= N; i++) {
    for (j = v[i]; j <= T; j++) {
      add(DP[j], DP[j - v[i]]);
    }
  }
  printf("%d\n", DP[T]);
}
