#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, q, t;
  cin >> n >> q >> t;
  vector<ll> v(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  vector<ll> adj(n + 1), vis(n + 1);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    adj[x] = y;
    vis[y] = 1;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ll sum = 0;
      for (int j = i; j; j = adj[j]) {
        sum += v[j];
        cnt++;
        v[j] = sum;
        if (adj[j]) t -= v[j];
      }
    }
  }
  if (cnt == n && t >= 0) {
    vector<ll> dp(t + 1);
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = v[i]; j <= t; j++) {
        dp[j] = (dp[j] + dp[j - v[i]]) % 1000000007;
      }
    }
    cout << dp[t];
  } else
    cout << 0;
}
