#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define endl '\n'

/* ------- */

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
//const int MOD = 998244353;

//ll qpow(ll x, ll n, ll m = MOD) {
////    assert(m > 1 and n >= 0);
////    if (x < 0 or x > m) x = (x % m + m) % m;
//    ll res = 1;
//    for (; n; n >>= 1, x = x * x % m)
//        if (n & 1) res = res * x % m;
//    return res;
//}

template<typename T>
void cmin(T &x, T y) {
    if (y < x) x = y;
}

template<typename T>
void cmax(T &x, T y) {
    if (y > x) x = y;
}

void purin_init() {}

static const int MAXN = 3e5 + 5;
int n, m, x;
ll a[MAXN];
set<int> G[MAXN];
int U[MAXN];
int V[MAXN];
vector<int> ans;

struct DisjointSetUnion {
    int root[MAXN], siz[MAXN];
    int find(int x) {
        return root[x] == x ? x : root[x] = find(root[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    void init(int n) {
        for (int i = 1; i <= n; ++i) root[i] = i, siz[i] = 1;
    }
    ll A(int u) {
        return a[find(u)];
    }
    bool merge(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return 0;
        if (siz[u] > siz[v])
            swap(u, v);
        root[u] = v;
        siz[v] += siz[u];
        a[v] += a[u] - x;
        for (auto xx : G[u]) {
            if (same(v, U[xx]) && same(v, V[xx]))
                continue;
            G[v].emplace(xx);
        }
        G[u].clear();
        return 1;
    }
} dsu;

set<pli> S;
void gao() {
    int u = prev(S.end())->second;
    S.erase(prev(S.end()));
    u = dsu.find(u);
    if (!G[u].empty()) {
        int xx = *G[u].begin();
        int v = U[xx];
        if (dsu.same(u, v)) {
            v = V[xx];
            if (dsu.same(u, v)) {
                G[u].erase(G[u].begin());
                if (!G[u].empty())
                    S.insert({dsu.A(u), u});
                return;
            }
        }
        assert(!dsu.same(u, v));
        if (dsu.A(u) + dsu.A(v) >= x) {
            dsu.merge(u, v);
            ans.emplace_back(xx);
        }
        S.insert({dsu.A(u), u});
        return;
    }
}

void purin_solve() {
    while (~scanf("%d%d%d", &n, &m, &x)) {
        ll sum = 0;
        for (int i = 1; i <= n; ++i) {
            scanf("%lld", &a[i]);
            sum += a[i];
            G[i].clear();
        }
        for (int i = 1; i <= m; ++i) {
            scanf("%d%d", &U[i], &V[i]);
            G[U[i]].insert(i);
            G[V[i]].insert(i);
        }
        if (sum < 1LL * (n - 1)*x) {
            puts("NO");
            continue;
        }
        puts("YES");
        ans.clear();
        S.clear();
        dsu.init(n);
        for (int i = 1; i <= n; ++i)
            S.insert({a[i], i});
        while (ans.size() < n - 1)
            gao();
        for (int i : ans)
            printf("%d\n", i);
    }
}

int main() {
#ifdef LOCAL
    freopen ("A.in", "r", stdin);
#endif // LOCAL
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(9);
//    int T;
//    cin >> T;
    purin_init();
    purin_solve();
    return 0;
}
