//#include <bits/stdc++.h>

#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

bool
check(int a, int b, int w, int& min, int& max)
{
	int imin = int(w / b);
	int imax = int(w / a);
	auto diff = float(b - a);
	min = imax;
	max = imin;
	bool is_ok = false;
	for (int i = imin; i <= imax; ++i) {
		for (int j = 0; j <= i; ++j) {
			auto ww = a * j;
			if ((w - ww) <= (i - j) * b) {
				is_ok = true;
				min = std::min(min, i);
				max = std::max(max, i);
				break;
			}
		}
	}

	return is_ok;
}

int
main(void)
{
	int a = 1, b = 2, w = 1;
	cin >> a >> b >> w;
	w = w * 1000;

	int min, max;
	bool is_ok;
	//is_ok = check(100, 200, 2000, min, max);
	//assert(is_ok && min == 10 && max == 20);
	//is_ok = check(120, 150, 2000, min, max);
	//assert(is_ok && min == 14 && max == 16);
	//is_ok = check(300, 333, 1000, min, max);
	//assert(is_ok == false);

	is_ok = check(a, b, w, min, max);


	if (is_ok)
		cout << min << " " << max << endl;
	else
		cout << "UNSATISFIABLE" << endl;

	return 0;
}

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; (i) < n;i++)
using namespace std;
using ll = long long;

vector<int> g[200000];
ll A[200000];
ll Max_cost[200000];

ll Find_Max(int u){
    if(Max_cost[u] != -1) return Max_cost[u];
    
    ll v = 0;
    for(int x:g[u]){
       v =  max({v,A[x],Find_Max(x)});
    }
    Max_cost[u] = v;
    return Max_cost[u];
}

int main(){
    int N,M;
    cin >> N >> M;

    rep(i,N){
        long long v;
        cin >> v; 
        A[i] = v;
    }

    rep(i,M){
        int u,v; cin >> u >> v; u--; v--;
        g[u].push_back(v);
    }

    rep(i,N) Max_cost[i] = -1;

    rep(i,N){
        if(Max_cost[i] == -1){
            Find_Max(i);
        }
    }

    ll result = - 1000000001;

    rep(i,N){
        /* cout << Max_cost[i] << endl; */
        if(Max_cost[i] == 0) continue;
        ll c = Max_cost[i] - A[i];
        result = max(result,c);
    }

    cout << result << endl;

    return 0;
}