A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap.

Overall the shop sells *n* clothing items, and exactly *m* pairs of clothing items match. Each item has its price, represented by an integer number of rubles. Gerald wants to buy three clothing items so that they matched each other. Besides, he wants to spend as little money as possible. Find the least possible sum he can spend.
The first input file line contains integers *n* and *m* — the total number of clothing items in the shop and the total number of matching pairs of clothing items (<img align="middle" class="tex-formula" src="https://espresso.codeforces.com/11d20cc08f8a72fe0056e3d0d36ad39fdff6b45f.png" style="max-width: 100.0%;max-height: 100.0%;"/>).

Next line contains *n* integers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>) — the prices of the clothing items in rubles.

Next *m* lines each contain a pair of space-separated integers *u*<sub class="lower-index">*i*</sub> and *v*<sub class="lower-index">*i*</sub> (1 ≤ *u*<sub class="lower-index">*i*</sub>, *v*<sub class="lower-index">*i*</sub> ≤ *n*, *u*<sub class="lower-index">*i*</sub> ≠ *v*<sub class="lower-index">*i*</sub>). Each such pair of numbers means that the *u*<sub class="lower-index">*i*</sub>-th and the *v*<sub class="lower-index">*i*</sub>-th clothing items match each other. It is guaranteed that in each pair *u*<sub class="lower-index">*i*</sub> and *v*<sub class="lower-index">*i*</sub> are distinct and all the unordered pairs (*u*<sub class="lower-index">*i*</sub>, *v*<sub class="lower-index">*i*</sub>) are different.
3 3
1 2 3
1 2
2 3
3 1
6
3 2
2 3 4
2 3
2 1
-1
4 4
1 1 1 1
1 2
2 3
3 4
4 1
-1
4 3
10 10 5 1
2 1
3 1
3 4
-1
4 0
9 8 2 10
-1
4 3
5 5 9 6
3 2
1 4
3 4
-1
4 3
5 1 10 1
2 1
3 2
1 4
-1
4 3
1 2 8 6
1 3
1 4
3 4
15
4 4
9 3 3 1
1 2
3 1
3 2
4 3
15
4 3
6 8 10 1
2 3
1 4
3 4
-1
4 5
4 10 3 9
1 2
3 1
3 2
2 4
4 3
17
4 2
2 9 8 4
1 3
4 2
-1
4 3
5 3 4 4
2 1
4 1
3 4
-1
6 6
39 15 73 82 37 40
2 1
5 1
1 6
2 6
6 3
4 6
94
6 7
85 2 34 6 83 61
1 2
2 3
4 2
4 3
1 5
4 5
6 3
42
6 8
64 44 5 31 14 16
1 2
1 3
1 4
2 5
3 5
6 1
6 3
6 4
85
6 8
36 19 99 8 52 77
2 1
3 1
4 2
4 3
1 5
5 4
1 6
6 2
132
6 5
59 69 52 38 93 53
4 2
1 5
6 1
4 6
5 6
205
6 11
95 81 74 94 60 69
3 2
1 4
4 2
3 4
1 5
5 2
5 3
1 6
2 6
3 6
4 6
215
6 8
69 36 41 23 91 35
1 2
3 1
3 2
1 4
3 4
3 5
5 4
4 6
133
6 6
33 76 98 59 4 69
1 2
3 2
5 1
2 5
4 5
6 5
113
6 6
92 56 15 83 30 28
3 1
4 1
2 5
5 4
2 6
6 3
-1
6 10
17 5 55 24 55 74
1 3
2 3
3 4
5 1
5 2
5 3
4 5
6 2
6 3
6 5
115
3 3
1000000 1000000 1000000
2 1
1 3
3 2
3000000
3 0
1 1 1
-1
3 3
100000 100000 100001
1 2
2 3
3 1
300001
3 3
1 1 999999
1 2
2 3
3 1
1000001
3 3
999999 1 1
1 2
2 3
3 1
1000001
3 3
1000000 1000000 1000000
1 2
2 3
1 3
3000000
n,m=list(map(int,input().split()))

arr=list(map(int,input().split()))

match=[]
for _ in range(m):
    l=list(map(int,input().split()))
    match.append(l)

def f(arr,n,m,match):
    d={}
    if n==3 and m==3:
        return sum(arr)
    if m<3 or n<3:
        return -1
    
    for i in match:
        i.sort()
        
        d[i[0]]=d.get(i[0],[])
        d[i[0]].append(i[1])
    
    ans=[]
    for i,v in d.items():
        if len(v)>=3:
            ans.append(i)
            ans.extend(v)
    
    if ans:
        s=0
        for i in ans:
            s+=arr[i-1]
        return s
    else:
        return -1

print(f(arr,n,m,match))
