#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
int n, q, t, a[512], p[512], d[512], v[100100] = {1};
int main(void) {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 0, x, y; i < q && cin >> x >> y; ++i) p[x] = y, ++d[y];
  int c = 0;
  for (int i = 1; t >= 0 && i <= n; ++i)
    if (!d[i]) {
      int s = 0;
      for (int j = i; t >= 0 && j > 0; j = p[j]) {
        ++c;
        s = (a[j] += s);
        if (p[j] > 0) t -= a[j];
      }
    }
  if (t < 0 || c < n)
    cout << 0 << endl;
  else {
    for (int i = 1; i <= n; ++i)
      for (int j = a[i]; j <= t; ++j)
        if ((v[j] += v[j - a[i]]) >= M) v[j] -= M;
    cout << v[t] << endl;
    int qqq;
  }
}
