#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[305];
bool root[305], vis[305];
int nxt[305];
int dp[305][100005];
int main() {
  int i, j;
  cin >> n >> q >> t;
  for ((i) = 0; (i) < (n); (i)++) cin >> a[i];
  memset(root, 1, sizeof(root));
  memset(nxt, -1, sizeof(nxt));
  for ((i) = 0; (i) < (q); (i)++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    nxt[x] = y;
    root[y] = 0;
  }
  for ((i) = 0; (i) < (n); (i)++)
    if (root[i]) {
      int x = i;
      while (1) {
        vis[x] = 1;
        if (nxt[x] == -1) break;
        a[nxt[x]] += a[x];
        t -= a[x];
        if (t < 0) return puts("0"), 0;
        x = nxt[x];
      }
    }
  for ((i) = 0; (i) < (n); (i)++)
    if (!vis[i]) return puts("0"), 0;
  dp[0][0] = 1;
  for ((i) = 0; (i) < (n); (i)++)
    for ((j) = 0; (j) < (t + 1); (j)++) {
      dp[i + 1][j] = dp[i][j];
      if (j < a[i]) continue;
      dp[i + 1][j] += dp[i + 1][j - a[i]];
      if (dp[i + 1][j] >= 1000000007) dp[i + 1][j] -= 1000000007;
    }
  cout << dp[n][t] << '\n';
  return 0;
}
