#include <bits/stdc++.h>
using namespace std;
template <typename input_type>
inline input_type input() {
  input_type inp;
  cin >> inp;
  return inp;
}
const int max_lg = 17, max_sz = 3e2 + 5, max_nm = 1e5 + 5;
const long long mod = 1e9 + 7;
bool have_ans = true, mark[max_sz], not_start[max_sz];
int sz, nm, dp[max_nm];
long long total, arr[max_sz];
vector<int> order, new_arr, graph[max_sz];
void DFS(int vrtx) {
  mark[vrtx] = true;
  order.push_back(vrtx);
  for (auto ngh : graph[vrtx]) {
    if (not mark[ngh]) {
      DFS(ngh);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  sz = input<int>(), nm = input<int>(), total = input<int>();
  for (int i = 0; i < sz; i++) {
    arr[i] = input<int>();
  }
  for (int i = 0; i < nm; i++) {
    pair<int, int> endpnt = {input<int>() - 1, input<int>() - 1};
    graph[endpnt.first].push_back(endpnt.second),
        not_start[endpnt.second] = true;
  }
  for (int i = 0; i < sz; i++) {
    if ((not mark[i]) and (not not_start[i])) {
      DFS(i);
      long long sum = 0;
      for (int j = 0; j < order.size(); j++) {
        total -= arr[order[j]] * (order.size() - (j + 1)), sum += arr[order[j]];
        if (total < 0) {
          cout << 0;
          return 0;
        } else {
          arr[order[j]] = sum;
        }
      }
      order.clear();
    }
  }
  for (int i = 0; i < sz; i++) {
    if (not mark[i]) {
      cout << 0;
      return 0;
    }
  }
  dp[0] = 1;
  for (int i = 0; i < sz; i++) {
    for (int j = arr[i]; j <= total; j++) {
      dp[j] += dp[j - arr[i]];
      dp[j] %= mod;
    }
  }
  cout << dp[total];
  return 0;
}
