#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
int fa[1000005], nxt[1000005];
int n, t, q;
long long a[1000005];
int pre[1000005], vis[1000005] = {0};
int dp[1000005] = {0};
long long sum = 0;
int find(int x) { return pre[x] = (pre[x] == x ? x : find(pre[x])); }
void dfs(int u, int c) {
  if (vis[u]) return;
  vis[u] = 1;
  if (fa[u] != -1) {
    dfs(fa[u], c + 1);
    a[u] += a[fa[u]];
  }
  if (c) sum += a[u];
}
int main() {
  cin >> n >> q >> t;
  memset(fa, -1, sizeof(fa));
  memset(nxt, -1, sizeof(nxt));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = i;
  }
  while (q--) {
    int u, v;
    cin >> u >> v;
    fa[v] = u;
    nxt[u] = v;
    int ra = find(u), rb = find(v);
    if (ra == rb) {
      puts("0");
      return 0;
    }
    pre[ra] = rb;
  }
  for (int i = 1; i <= n; i++)
    if (nxt[i] == -1) dfs(i, 0);
  if (sum > t) {
    puts("0");
    return 0;
  }
  dp[sum] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = a[i]; j <= t; j++) {
      dp[j] += dp[j - a[i]];
      if (dp[j] >= 1000000007) dp[j] -= 1000000007;
    }
  }
  printf("%d\n", dp[t]);
  return 0;
}
