#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
long long lq[300005];
priority_queue<pair<long long,int> > q;
struct hlydl{
	int x,y,nxt,id;
}e[600006];
int head[300005],fir[300005];
int num=1;
void addedge(int x,int y,int z)
{
	if(!fir[x])fir[x]=num;
	e[num].x=x;
	e[num].y=y;
	e[num].id=z;
	e[num].nxt=head[x];
	head[x]=num++;
}
bool mer[300005];
int f[300005];
int find(int x)
{
	return x==f[x]?x:f[x]=find(f[x]);
}
void merge(int x,int y)
{
	int fx=find(x),fy=find(y);
	f[fy]=fx;
}
int main()
{
	int n,m,v;
	scanf("%d%d%d",&n,&m,&v);
	long long sum=0;
	for(int i=1;i<=n;i++)
	f[i]=i,scanf("%d",&lq[i]),sum+=lq[i],q.push(make_pair(lq[i],i));
	if(sum<(long long)v*(n-1))
	{
		puts("NO");
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y,i);
		addedge(y,x,i);
	}
	puts("YES");
	int cnt=0;
	while(!q.empty())
	{
		if(cnt==n-1)return 0;
		pair<long long,int> x=q.top();
		//cout<<x.second<<":"<<endl;
		q.pop();
		if(lq[x.second]!=x.first)continue;
		if(mer[x.second])continue;
		int las=0;
		if(head[x.second])
		//for(int i=head[x.second];i;i=e[i].nxt)cout<<e[i].y<<" ";
		for(int i=head[x.second];i;i=e[i].nxt)
		{
			int to=find(e[i].y);
			if(to==x.second)
			{
				if(las==0)head[x.second]=e[i].nxt;
				else e[las].nxt=e[i].nxt;
				continue;
			}
			if(lq[x.second]+lq[to]>=v)
			{
				if(las==0)head[x.second]=e[i].nxt;
				else e[las].nxt=e[i].nxt;
				lq[x.second]=lq[x.second]+lq[to]-v;
				if(head[x.second]==0)
				head[x.second]=head[to];
				else
				e[fir[x.second]].nxt=head[to];
				fir[x.second]=fir[to];
				mer[to]=1;
				merge(x.second,to);
				printf("%d\n",e[i].id);
				cnt++;
				break;
			}
			las=i;
		}
		if(head[x.second])
		q.push(make_pair(lq[x.second],x.second));
	}
	return 0;
}
