#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int mod = 1e9 + 7;
int a[N], f[N], dp[N], to[N];
bool flag[N];
int main() {
  int n, q, t;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    to[y] = x;
    flag[x] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    int x = a[i], u = to[i], cnt = 0;
    while (u) {
      cnt++;
      if (cnt > 400) {
        printf("%d\n", 0);
        return 0;
      }
      x += a[u];
      u = to[u];
    }
    if (flag[i]) t -= x;
    if (t < 0) {
      printf("%d\n", 0);
      return 0;
    }
    f[i] = x;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = f[i]; j <= t; ++j) {
      dp[j] = (dp[j] + dp[j - f[i]]) % mod;
    }
  }
  printf("%d\n", dp[t]);
  return 0;
}
