#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long OO = 1LL << 10;
const int MOD = 1000000007;
long long dp[100005];
int w[305];
int father[305], ind[305];
int n, Q, t;
void init() {
  memset(father, -1, sizeof father);
  memset(ind, 0, sizeof ind);
}
bool ok() {
  while (Q--) {
    int pos = 0;
    for (int i = 1; i <= n; i++) {
      if (father[i] != -1 && ind[i] == 0) {
        pos = i;
        break;
      }
    }
    if (pos == 0) return false;
    int pre = father[pos];
    father[pos] = -1;
    ind[pre]--;
    w[pre] += w[pos];
    t -= w[pos];
    if (t < 0) return false;
  }
  return true;
}
void DP() {
  memset(dp, 0, sizeof dp);
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = w[i]; j <= t; j++) {
      dp[j] = (dp[j] + dp[j - w[i]] + MOD) % MOD;
    }
  }
  cout << dp[t] << endl;
}
int main() {
  int u, v;
  while (scanf("%d %d %d", &n, &Q, &t) != EOF) {
    init();
    for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
    for (int i = 1; i <= Q; i++) {
      scanf("%d %d", &u, &v);
      father[u] = v;
      ind[v]++;
    }
    if (!ok()) {
      puts("0");
      continue;
    }
    DP();
  }
  return 0;
}
