#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline int read() {
  int x = 0, o = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, q, t;
int f[100050];
int a[550], so[550], fa[550];
int main() {
  n = read(), q = read(), t = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= q; i++) {
    int v, x;
    v = read(), x = read();
    so[x]++;
    fa[v] = x;
  }
  for (int i = 1; i <= q; i++) {
    int pos = 0;
    for (int j = 1; j <= n; j++) {
      if ((fa[j]) && (!so[j])) {
        pos = j;
        break;
      }
    }
    if (!pos) {
      puts("0");
      return 0;
    }
    int pre = fa[pos];
    fa[pos] = 0;
    so[pre]--;
    t -= a[pos];
    a[pre] += a[pos];
    if (t < 0) {
      puts("0");
      return 0;
    }
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = a[i]; j <= t; j++) f[j] = (f[j] + f[j - a[i]]) % mod;
  }
  cout << f[t] << endl;
  return 0;
}
