#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[310];
int p[310];
bool deg[310];
int que[310], dp[100010];
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int s, e;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &s, &e);
    p[s] = e;
    deg[e] = 1;
  }
  int num = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i] && !deg[i]) que[num++] = i;
  }
  for (int i = 0; i < num; i++) {
    s = que[i];
    if (p[p[s]]) que[num++] = p[s];
  }
  if (num != q) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < q; i++) {
    s = que[i];
    e = p[s];
    a[e] += a[s];
    t -= a[s];
    if (t < 0) {
      printf("0\n");
      return 0;
    }
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = a[i]; j <= t; j++) dp[j] = (dp[j] + dp[j - a[i]]) % 1000000007;
  printf("%d\n", dp[t]);
  return 0;
}
