#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
const int null = 0;
using namespace std;
template <class T>
int size(const T &a) {
  return int(a.size());
}
template <class T>
T abs(const T &a) {
  return (a < 0 ? -a : a);
}
template <class T>
T sqr(const T &a) {
  return a * a;
}
const int max_n = 500, max_m = 100010;
int a[max_n];
int stin[max_n];
int v[max_n];
bool was[max_n];
long long dfs(int i, int c = 0) {
  was[i] = true;
  int nx = v[i];
  if (nx == -1) {
    return a[i] * c;
  }
  long long res = a[i] * c + dfs(nx, c + 1);
  a[i] += a[nx];
  return res;
}
int cnt[max_m];
int main() {
  int n, q;
  long long t;
  scanf("%d %d", &n, &q);
  cin >> t;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  memset(v, -1, sizeof(v));
  for (int i = 0; i < q; i++) {
    int v1, v2;
    scanf("%d %d", &v1, &v2);
    v1--, v2--;
    v[v2] = v1;
    stin[v1] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (!stin[i]) {
      t -= dfs(i);
      if (t < 0) {
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (!was[i]) {
      t = -1;
    }
  }
  if (t < 0) {
    printf("0\n");
    return 0;
  }
  int mod = 1e9 + 7.1;
  cnt[0] = 1;
  for (int j = 0; j < n; j++) {
    int di = a[j];
    for (int i = di; i <= t; i++) {
      cnt[i] += cnt[i - di];
      if (cnt[i] >= mod) cnt[i] -= mod;
    }
  }
  printf("%d\n", cnt[t]);
  return 0;
}
