#include <bits/stdc++.h>
using namespace std;
const int max_n = 300;
const int max_t = 1000000;
const int mod = 1000000007;
void add(int &a, int b) {
  a += b;
  a %= mod;
}
int n, q;
long long t;
int adj[max_n][max_n];
long long rw[max_n], w[max_n];
int cnt[max_t];
int main() {
  scanf("%d %d %lld", &n, &q, &t);
  for (int i = 0; i < n; i++) scanf("%lld", &rw[i]);
  for (int i = 0; i < q; i++) {
    int n0, n1;
    scanf("%d %d", &n0, &n1);
    n0--;
    n1--;
    adj[n0][n1] = 1;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        if (adj[j][i] && adj[i][k]) adj[j][k] = 1;
  for (int i = 0; i < n; i++)
    if (adj[i][i]) printf("0\n"), exit(0);
  for (int i = 0; i < n; i++) {
    t += rw[i];
    w[i] = rw[i];
    for (int j = 0; j < n; j++)
      if (adj[j][i]) w[i] += rw[j];
    t -= w[i];
  }
  if (t < 0) printf("0\n"), exit(0);
  cnt[0] = 1;
  for (int i = 0; i < n; i++)
    for (long long j = 0; j <= t - w[i]; j++) add(cnt[j + w[i]], cnt[j]);
  printf("%d\n", cnt[t]);
  return 0;
}
