#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int cnt[305];
int fa2[305];
int fa[305];
int son[305];
int dp[305][100005];
int pre[100005];
int fnd(int x) { return (fa2[x] == x ? x : fa2[x] = fnd(fa2[x])); }
void merge(int x, int y) {
  x = fnd(x);
  y = fnd(y);
  if (x == y) {
    puts("0");
    exit(0);
  }
  fa2[y] = x;
}
int main() {
  scanf("%d %d %d", &n, &q, &t);
  for (int i = 1; i <= n; i++) fa[i] = fa2[i] = i;
  for (int i = 1; i <= n; i++) scanf("%d", &pre[i]);
  for (int i = 1; i <= q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    cnt[a]++;
    cnt[b]++;
    merge(a, b);
    fa[b] = a;
    son[a] = b;
  }
  for (int i = 1; i <= n; i++) {
    if (fa[i] == i) {
      for (int j = son[i]; j != 0; j = son[j]) pre[j] += pre[fa[j]];
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= t; j++) {
      if (j - pre[i] >= 0) (dp[i][j] += dp[i][j - pre[i]]) %= 1000000007;
      if (son[i] == 0)
        (dp[i][j] += dp[i - 1][j]) %= 1000000007;
      else if (j >= pre[i])
        (dp[i][j] += dp[i - 1][j - pre[i]]) %= 1000000007;
    }
  printf("%d\n", dp[n][t]);
  return 0;
}
