#include <bits/stdc++.h>
using namespace std;
struct point {
  point *next;
  int to;
} * head[350];
void dfs(int);
int a[350], pa[350], dp[100050], t, find(int);
inline void read(int &), Union(int, int), link(int, int);
int main() {
  int n, q;
  read(n), read(q), read(t);
  for (int i(1); i <= n; ++i) read(a[i]), pa[i] = i;
  for (int i(1), u, v; i <= q; ++i) {
    read(u), read(v);
    if (find(u) == find(v)) return puts("0"), 0;
    Union(u, v), link(v, u);
  }
  for (int i(1); i <= n; ++i)
    if (pa[i] == i) dfs(i);
  if (t < 0) return puts("0"), 0;
  for (int i(dp[0] = 1), j; i <= n; ++i)
    for (j = a[i]; j <= t; ++j) (dp[j] += dp[j - a[i]]) %= 1000000007;
  printf("%d", dp[t]);
  return 0;
}
void dfs(int x) {
  for (point *i(head[x]); i != NULL; i = i->next) dfs(i->to), a[x] += a[i->to];
  t -= (pa[x] != x) * a[x];
  if (t < 0) t = -1;
}
inline void link(int u, int v) { head[u] = new point{head[u], v}; }
inline void Union(int u, int v) { u = find(u), v = find(v), pa[u] = v; }
int find(int x) {
  if (x == pa[x]) return x;
  return pa[x] = find(pa[x]);
}
inline void read(int &x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
