#include <bits/stdc++.h>   int Flag, sum, flag[105], n, m, a, b, A[105], map[105][105];   void dfs(int last_last, int last) {     int S;     flag[last] = 1;     for (int i = 1; i <= n; i++) {       if (!map[last][i]) continue;       if (map[i][last_last]) {         S = A[i] + A[last] + A[last_last];         if (S < sum) sum = S;       }       if (!flag[i]) dfs(last, i);     }   }   int main() {     while (~scanf( %d%d , &n, &m)) {       memset(flag, 0, sizeof(flag));       memset(map, 0, sizeof(map));       for (int i = 1; i <= n; i++) scanf( %d , &A[i]);       for (int i = 1; i <= m; i++) {         scanf( %d%d , &a, &b);         map[a][b] = 1;         map[b][a] = 1;       }       Flag = 0;       sum = 99999999;       dfs(0, 1);       if (sum == 99999999)         printf( -1 n );       else         printf( %d n , sum);     }     return 0;   }   