#include <bits/stdc++.h>
using namespace std;
int n, q, t, a[210000], x, y, to[210000], dp[210000];
bool in[210000], used[210000];
void dfs(int k) {
  used[k] = true;
  if (!to[k])
    return;
  else {
    a[to[k]] += a[k];
    dfs(to[k]);
    t -= a[k];
    if (t < 0) t = -1;
  }
}
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    to[x] = y;
    in[y] = true;
  }
  for (int i = 1; i <= n; i++)
    if (!in[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (!used[i]) {
      printf("0\n");
      return 0;
    }
  if (t < 0) {
    printf("0\n");
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = a[i]; j <= t; j++) dp[j] = (dp[j - a[i]] + dp[j]) % 1000000007;
  printf("%d\n", dp[t]);
}
