// Created by calabash_boy
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#ifdef __LOCAL_DEBUG__
#define _debug(fmt, ...) fprintf(stderr, "\033[91m[%s %3d]: " fmt "\n\033[0m", \
                                 __func__, __LINE__, ##__VA_ARGS__)
#else
#define _debug(...) (void(0))
#endif
#define PB(x) push_back(x)
#define rep(i, l, r) for (int i = l, _ = r; i < _; i++)
#define REP(i, l, r) for (int i = l, _ = r; i <= _; i++)
#define leave(x)            \
    do                      \
    {                       \
        cout << #x << endl; \
        fflush(stdout);     \
        return 0;           \
    } while (0);
#define untie                        \
    do                               \
    {                                \
        ios::sync_with_stdio(false); \
        cin.tie(nullptr);            \
        cout.tie(nullptr);           \
    } while (0)
#define range(x) x.begin(), x.end()
typedef long long LL;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll inf_ll = 0x3f3f3f3f3f3f3f3fLL;
mt19937 wdy(time(0));
/************* header ******************/
const int maxn = 3e5 + 10;
vector<pair<int, int>> E[maxn];
int start_pos[maxn];
vector<int> ans;
struct UFS
{
    int fa[maxn];
    UFS()
    {
        for (int i = 1; i < maxn; i++)
        {
            fa[i] = i;
        }
    }
    int find(int x)
    {
        return fa[x] == x ? x : fa[x] = find(fa[x]);
    }
    void merge(int x, int y)
    {
        fa[find(y)] = find(x);
    }
} ufs;

ll a[maxn];

pair<int, int> out[maxn];
int main()
{
    int n, m, x;
    scanf("%d%d%d", &n, &m, &x);
    ll sum = 0;
    priority_queue<pair<ll, int>> heap;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
        sum += a[i];
        heap.push({a[i], i});
    }
    if (sum >= 1ll * (n - 1) * x)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
        return 0;
    }
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        E[x].push_back({y, i});
        E[y].push_back({x, i});
    }
    vector<int> ans(0);
    while (heap.size() > 1)
    {
        auto pr = heap.top();
        heap.pop();
        ll ai;
        int i;
        tie(ai, i) = pr;
        if (ufs.find(i) != i || ai != a[i])
            continue;
        int remove_cnt = 0;
        for (;start_pos[i] < E[i].size(); start_pos[i] ++)
        {
            auto it = E[i][start_pos[i]];
            int j, id;
            tie(j, id) = it;
            if (ufs.find(j) == i)
            {
                continue;
            }
            else
            {
                ans.push_back(id);
                j = ufs.find(j);
                if (E[j].size() - start_pos[j] < E[i].size() - start_pos[i])
                    ufs.merge(i, j);
                else
                    ufs.merge(j,i);
                int root = ufs.find(i);
                int other = j ^ i ^ root;
                for (;start_pos[other] < E[other].size(); start_pos[other] ++)
                {
                    auto itt = E[other][start_pos[other]];
                    if (ufs.find(itt.first) != root)
                        E[root].push_back(itt);
                }
                E[other].clear();
                a[root] = a[root] + a[other] - x;
                heap.push({a[root], root});
                break;
            }
        }
    }
    for (int x : ans)
    {
        printf("%d\n", x);
    }
    return 0;
}