#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int X = 1e5 + 10;
const int N = 505;
int n, q, t, to[N], a[N], dp[X];
bool vis[N], child[N];
inline int add(int x, int y) {
  if (x + y >= mod) {
    return x + y - mod;
  }
  return x + y;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int bi, ci;
  for (int i = 0; i < q; i++) {
    cin >> bi >> ci;
    to[bi] = ci;
    child[ci] = true;
  }
  int cnt = 0;
  for (int v = 1; t >= 0 && v <= n; v++) {
    if (child[v]) continue;
    for (int u = v; t >= 0 && u > 0; u = to[u]) {
      cnt++;
      vis[u] = true;
      a[to[u]] += a[u];
      if (to[u]) t -= a[u];
    }
  }
  if (cnt < n || t < 0) {
    cout << 0 << '\n';
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int s = a[i]; s <= t; s++) {
      dp[s] = add(dp[s], dp[s - a[i]]);
    }
  }
  cout << dp[t] << '\n';
  return 0;
}
