#include <bits/stdc++.h>
using namespace std;
const int N = 310, mod = 1e9 + 7, T = 1e5 + 10;
int n, q, t, a[N], s[N], d[N], f[T];
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (register int i = 1; i <= q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    ++s[y];
    d[x] = y;
  }
  while (q--) {
    int pos = 0, pre = 0;
    for (register int i = 1; i <= n; ++i)
      if (d[i] && !s[i]) {
        pos = i;
        pre = d[i];
        break;
      }
    if (!pos) {
      puts("0");
      return 0;
    }
    d[pos] = 0;
    --s[pre];
    t -= a[pos];
    a[pre] += a[pos];
    if (t < 0) {
      puts("0");
      return 0;
    }
  }
  f[0] = 1;
  for (register int i = 1; i <= n; ++i)
    for (register int j = a[i]; j <= t; ++j) f[j] = (f[j] + f[j - a[i]]) % mod;
  printf("%d\n", f[t]);
  return 0;
}
