#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 1e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long out[maxn];
long long in[maxn];
long long a[maxn];
long long b[maxn];
long long dp[2][maxn];
int main() {
  fill(out, out + maxn, -1);
  fill(in, in + maxn, -1);
  long long n, q, t;
  cin >> n >> q >> t;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < q; i++) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    out[u] = v;
    in[v] = u;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (out[j] == -1) {
        b[j] = a[j];
      } else {
        if (b[out[j]] != 0) {
          b[j] = b[out[j]] + a[j];
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (b[i] == 0) {
      cout << 0;
      return 0;
    }
    if (in[i] != -1) {
      t -= b[i];
    }
  }
  if (t < 0) {
    cout << 0;
    return 0;
  }
  dp[1][0] = 1;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < b[i]; j++) {
      dp[i & 1][j] = dp[(i & 1) ^ 1][j];
    }
    for (long long j = b[i]; j <= t; j++) {
      dp[i & 1][j] =
          ((long long)dp[(i & 1) ^ 1][j] + dp[(i & 1)][j - b[i]]) % mod;
    }
  }
  cout << dp[(n - 1) & 1][t];
}
