#include <bits/stdc++.h>   using namespace std;   int n, m, a[111], ans = 1e9;   set<int> s[111];   int main() {     ios_base ::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int i = 0, x, y; i < m; ++i) {       cin >> x >> y;       s[x].insert(y);       s[y].insert(x);     }     for (int i = 1; i < n - 1; ++i) {       for (int j = i + 1; j < n; ++j) {         if (s[i].count(j)) {           for (int k = j + 1; k <= n; ++k) {             if (s[i].count(k) && s[j].count(k)) {               ans = min(a[i] + a[j] + a[k], ans);             }           }         }       }     }     if (ans == 1e9) {       cout << -1;     } else {       cout << ans;     }   }   