#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e5 + 10;
constexpr int MOD = 1e9 + 7;
long long n, q, t, a[N], u, v, c[N], dp[N], in[N];
vector<int> node[N];
bool mark[N], flag;
void dfs(int v, int s) {
  mark[v] = true;
  s += a[v];
  c[v] = s;
  if ((int)node[v].size()) t -= s;
  for (auto i : node[v]) {
    if (!mark[i])
      dfs(i, s);
    else
      flag = true;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < q; i++) {
    cin >> u >> v;
    node[u].push_back(v);
    in[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i] && !in[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    if (!mark[i]) flag = true;
  if (flag || t < 0) {
    cout << 0 << '\n';
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = c[i]; j <= t; j++) dp[j] = (dp[j] + dp[j - c[i]]) % MOD;
  cout << dp[t] << '\n';
  return 0;
}
