#include <bits/stdc++.h>   using namespace std;   int arr[102][102] = {0};   int main() {     int n, m, a, b, sum = -1, minsum = -1;     scanf( %d%d , &n, &m);     int cost[n + 1];     for (int i = 1; i <= n; i++) {       scanf( %d , &cost[i]);     }     for (int i = 1; i <= m; i++) {       scanf( %d%d , &a, &b);       arr[a][b] = arr[b][a] = 1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 1; k <= n; k++) {           if (sum == -1 && j != k && i != j && j != k && arr[i][j] == 1 &&               arr[j][k] == 1 && arr[k][i] == 1)             minsum = sum = cost[i] + cost[j] + cost[k];           else if (j != k && i != j && j != k && arr[i][j] == 1 &&                    arr[j][k] == 1 && arr[k][i] == 1) {             sum = cost[i] + cost[j] + cost[k];             if (minsum > sum) minsum = sum;           }         }       }     }     printf( %d n , minsum);     return 0;   }   