#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e9 + 7);
int main(int argc, char const *argv[]) {
  int n, q, t;
  cin >> n >> q >> t;
  vector<long long> a(n + 1, 0);
  for (int i = 0; i < n; i++) {
    long long t;
    cin >> t;
    a[i + 1] = t;
  }
  vector<int> pre(n + 1, -1);
  vector<int> to(n + 1, -1);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    to[x] = y;
    pre[y] = x;
  }
  int count = 0;
  int cnt = 0;
  long long start = 0;
  vector<long long> object_w(n + 1, 0);
  unordered_map<int, vector<int>> graph;
  for (int i = 1; i <= n; i++) {
    if (pre[i] == -1) {
      cnt++;
      long long sum = 0;
      int cur = i;
      int len = 1;
      sum += a[i];
      object_w[i] = sum;
      graph[cnt].push_back(cur);
      while (to[cur] != -1) {
        int next_id = to[cur];
        graph[cnt].push_back(next_id);
        sum += a[next_id];
        object_w[next_id] = sum;
        cur = next_id;
        len++;
      }
      count += len;
      if (len > 1) {
        int temp_count = 0;
        while (pre[cur] != -1) {
          int pre_id = pre[cur];
          temp_count++;
          start += temp_count * a[pre_id];
          cur = pre_id;
        }
      }
    }
  }
  if (count != n || start > t) {
    cout << 0 << endl;
    return 0;
  }
  vector<long long> dp(150000, 0);
  dp[start] = 1;
  for (int i = 1; i <= cnt; i++) {
    for (int cur : graph[i]) {
      for (long long j = max(object_w[cur], start); j <= t; j++) {
        dp[j] += dp[j - object_w[cur]];
        dp[j] %= mod;
      }
    }
  }
  cout << dp[t] << endl;
  return 0;
}
