#include <bits/stdc++.h>
using namespace std;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef WA_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

using ll  = long long;
using ull = unsigned long long;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=int(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=int(a);i>=(int)(b);i--)
const int mod  = 1e9+7;
const int inf  = 0x3f3f3f3f;
const int maxn = 1e5+10;
int main() {
#ifndef WA_DEBUG
    ios::sync_with_stdio(false);cin.tie(nullptr);
#endif
    int n,m,x;
    cin>>n>>m>>x;
    vector<ll> a(n+1);
    ll sum=0;
    rep(i,1,n) {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<1ll*(n-1)*x) {
        cout<<"NO"<<'\n';
        return 0;
    }
    vector<pair<int,int>> edge(m+1);
    vector<vector<int>> g(n+1);
    rep(i,1,m) {
        cin>>edge[i].fi>>edge[i].se;
        g[edge[i].fi].pb(i);
        g[edge[i].se].pb(i);
    }
    vector<int> ans(n-1);
    vector<bool> vis(n+1);
    int l=0,r=n-2;
    function<void(int,int)> dfs=[&](int now,int fa) {
        vis[now]=true;
        for(int id:g[now]) {
            int to=edge[id].fi^edge[id].se^now;
            if(to==fa||vis[to]) continue;
            dfs(to,now);
            if(a[to]+a[now]>=x) {
                a[now]+=a[to]-x;
                ans[l++]=id;
            }
            else ans[r--]=id;
        }
    };
    dfs(1,0);
    cout<<"YES"<<'\n';
    for(int x:ans) cout<<x<<'\n';
    return 0;
}
