#include <bits/stdc++.h>
using namespace std;
int bigger[305], a[305], ins[305], d[305], used[305];
int f[100005];
int t;
void trace(int p, int sum) {
  if (ins[p]) {
    throw "cycle";
  }
  ins[p] = true;
  t -= sum;
  if (t < 0) throw "out of quota";
  if (bigger[p]) {
    trace(bigger[p], sum + a[p]);
    used[p] = true;
  }
  a[p] += sum;
  ins[p] = false;
}
int main() {
  int n, q;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= q; i++) {
    int b, c;
    scanf("%d%d", &b, &c);
    bigger[b] = c;
    d[c]++;
  }
  try {
    for (int i = 1; i <= n; i++)
      if (d[i] == 0) trace(i, 0);
    for (int i = 1; i <= n; i++) {
      if ((!used[i] && bigger[i])) {
        throw "cycle";
      }
    }
  } catch (...) {
    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]]) % 1000000007;
  printf("%d\n", f[t]);
  return 0;
}
