#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ '0');
    ch = getchar();
  }
  return f ? x : -x;
}
const int N = 3e2 + 10, mod = 1e9 + 7;
int n, q, t, a[N], to[N], in[N], f[100010];
int main() {
  n = read(), q = read(), t = read();
  for (int i = (1), ed = (n); i <= ed; ++i) a[i] = read();
  for (int i = (1), ed = (q); i <= ed; ++i) {
    int u = read(), v = read();
    ++in[v];
    to[u] = v;
  }
  while (q--) {
    int u = 0;
    for (int i = 1; i <= n && !u; ++i)
      if (!in[i] && to[i]) u = i;
    if (!u) {
      puts("0");
      return 0;
    }
    --in[to[u]];
    a[to[u]] += a[u];
    t -= a[u];
    to[u] = 0;
    if (t < 0) {
      puts("0");
      return 0;
    }
  }
  f[0] = 1;
  for (int i = (1), ed = (n); i <= ed; ++i)
    for (int j = (a[i]), ed = (t); j <= ed; ++j)
      f[j] = (f[j] + f[j - a[i]]) % mod;
  printf("%d\n", f[t]);
  return 0;
}
