#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int inf = 0x3f3f3f3f;
template <class T>
void show(T a, int n) {
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
  cout << endl;
}
template <class T>
void show(T a, int r, int l) {
  for (int i = 0; i < r; ++i) show(a[i], l);
  cout << endl;
}
const int N = 3e3 + 111;
long long a[N];
int sm[N];
int bg[N];
long long value[N];
int mod = 1e9 + 7;
int dp[100001];
int main() {
  long long n, q, t, i, j, x, y;
  cin >> n >> q >> t;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sm[i] = bg[i] = i;
  }
  while (q--) {
    cin >> x >> y;
    sm[x] = y;
    bg[y] = x;
  }
  for (i = 1; i <= n; i++) {
    long long tp = i;
    long long tmp = 0;
    long long rcd = 0;
    if (bg[i] == i)
      while (sm[tp] != tp) {
        t -= tmp;
        tmp += a[tp];
        tp = sm[tp];
        rcd++;
        if (rcd > n) {
          puts("0");
          return 0;
        }
      }
    t -= tmp;
  }
  for (i = 1; i <= n; i++) {
    long long tp = i, tmp = 0;
    long long rcd = 0;
    while (bg[tp] != tp) {
      tmp += a[tp];
      tp = bg[tp];
      rcd++;
      if (rcd > n) {
        puts("0");
        return 0;
      }
    }
    tmp += a[tp];
    value[i] = tmp;
  }
  if (t < 0) {
    puts("0");
    return 0;
  }
  dp[0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = value[i]; j <= t; j++) {
      dp[j] = (dp[j] + dp[j - value[i]]) % mod;
    }
  }
  cout << dp[t];
  return 0;
}
