from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

# In[]:
# N = M = 5
# DD = [3,4,3,5,7]
# uvs = [(1,2),(1,3),(3,2),(4,2),(4,5)]

# In[]:
N,M = inpl()
DD = inpl()
lines = [[] for _ in range(N)]


# In[]:
minD = min(DD)
Start = None
lines = [[] for _ in range(N)]
for _ in range(M):
    u,v = inpl()
    u -= 1; v -= 1
    lines[u].append(v)
    lines[v].append(u)
    if DD[u] == DD[v] == minD:
        Start = (u,v)


if Start is None:
    print(-1)
else:
    assert False
