#include "bits/stdc++.h"
using namespace std;

#define int long long
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}

#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define fset(it,s)  for(auto it = s.begin(); it != s.end(); it++)

#define lb          lower_bound
#define ub          upper_bound
#define bg(i)       i.begin()
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void amax(int &a, int b) { a = max(a, b);}
void amin(int &a, int b) { a = min(a, b);}
const int INF = 5e18;
#define MOD         1000000007
#define N	    	600001 //for stack, queues decrease the N to 1e5

int a[N],x;
vector<pii> v[N];
int parent[N],sz[N];
int getpar(int i) {
    if(parent[i] == i)
        return i;
    else
        return parent[i] = getpar(parent[i]);
}
void unite(int A,int B) {
	if(sz[A] >= sz[B])
		swap(A, B);
	sz[B] += sz[B];
	a[B] += a[A] - x;
	parent[A] = B;
	if(sz(v[B]) < sz(v[A]))
		swap(v[B],v[A]);
	for(auto x:v[A])
		v[B].pb(x);
	return;
}
void solve(){
	int n,m;
	cin >> n >> m >> x;
	int tot = 0;
	rep(i,1,n+1){
		cin >> a[i];
		tot += a[i];
        parent[i] = i;
        sz[i] = 1;
	}
	if(tot < x * (n - 1)) {
		cout << "NO\n";
		return;
	}
	rep(i,0,m){
		int x,y;
		cin >> x >> y;
		v[x].pb(mp(y,i));
		v[y].pb(mp(x,i));
	}
	set<pii,greater<pii> > s;
	rep(i,1,n+1)
		s.insert(mp(a[i],i));
    vi ans;
	while(!s.empty()){
		auto cur = *s.begin();
		s.erase(s.begin());
		int A = cur.y;
		while(!v[A].empty()){
			int B = v[A].back().x;
			int id = v[A].back().y;
            int p = getpar(B);
			v[A].pop_back();
			if(A == p) 
				continue;
			ans.pb(id+1);
			s.erase(mp(a[p], p));
			unite(A, p);
			p = getpar(B);
			s.insert(mp(a[p],p));
			break;
		}
	}
	cout << "YES\n";
	for(int x:ans){
		cout << x << "\n";
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


