#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m, t, v[110001], a[501], d[501], p[501];
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    p[x] = y;
    d[y]++;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!d[i] && t >= 0) {
      int sum = 0;
      for (int j = i; j; j = p[j]) {
        cnt++;
        sum = a[j] += sum;
        if (p[j]) t -= a[j];
        if (t < 0) break;
      }
    }
  if (t < 0 || cnt < n) puts("0"), exit(0);
  v[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = a[i]; j <= t; j++) v[j] = (v[j] + v[j - a[i]]) % mod;
  printf("%d\n", v[t]);
}
