#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const long long MOD = 1e9 + 7;
long long dp[MAXN];
int a[MAXN], w[MAXN];
int adj[MAXN];
int N, Q, T;
int main() {
  while (scanf("%d%d%d", &N, &Q, &T) != EOF) {
    for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
    memset(adj, 0, sizeof(adj));
    for (int i = 1; i <= Q; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      adj[v] = u;
    }
    for (int i = 1; i <= N; i++) {
      int cur = i;
      for (cur = adj[cur]; cur != i && cur != 0; cur = adj[cur]) w[i] += a[cur];
      if (cur == i) {
        puts("0");
        return 0;
      }
      T -= w[i];
      if (T < 0) {
        puts("0");
        return 0;
      }
      w[i] += a[i];
    }
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
      for (int j = w[i]; j <= T; j++) dp[j] = (dp[j] + dp[j - w[i]]) % MOD;
    }
    cout << dp[T] << endl;
  }
  return 0;
}
