#include <bits/stdc++.h>
using namespace std;
long long n, q, t, f[306][101000], x, y, du[400], to[400], a[400];
const long long MOD = 1e9 + 7;
void Dfs(long long x) {
  du[x] = -1;
  if (!to[x]) return;
  a[to[x]] += a[x];
  t -= a[x];
  Dfs(to[x]);
}
signed main(void) {
  scanf("%lld%lld%lld", &n, &q, &t);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= q; i++) {
    scanf("%lld%lld", &x, &y);
    to[x] = y;
    du[y]++;
  }
  for (long long i = 1; i <= n; i++) {
    if (du[i]) continue;
    Dfs(i);
  }
  for (long long i = 1; i <= n; i++)
    if (du[i] > 0) return 0 * puts("0");
  if (t < 0) return 0 * puts("0");
  f[0][0] = 1;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= t; j++) {
      f[i][j] = f[i - 1][j];
      if (j >= a[i]) f[i][j] = (f[i][j] + f[i][j - a[i]]) % MOD;
    }
  printf("%lld\n", f[n][t]);
  return 0;
}
