#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
int n, T, q;
int a[N], h[N], t[N];
long long dp[N], s[N], sub = 0, i, j;
vector<int> e[N];
int main() {
  memset(h, 0, sizeof(h));
  memset(t, 0, sizeof(t));
  int u, v, cnt = 0;
  scanf("%d%d%d", &n, &q, &T);
  for (i = 1; i <= n; i++) scanf("%d", a + i);
  while (q--) {
    scanf("%d%d", &u, &v);
    h[v] = u;
    t[u] = v;
  }
  for (i = 1; i <= n; i++)
    if (h[i] == 0) {
      int tmp = 0;
      for (j = i; j; j = t[j]) {
        tmp += a[j];
        s[j] = tmp;
        cnt++;
        if (t[j]) sub += s[j];
      }
    }
  if (cnt != n || T < sub) {
    puts("0");
    return 0;
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  T -= sub;
  for (i = 1; i <= n; i++)
    for (j = s[i]; j <= T; j++) dp[j] = (dp[j - s[i]] + dp[j]) % 1000000007;
  printf("%I64d\n", dp[T]);
  return 0;
}
