#include <bits/stdc++.h>
using namespace std;
int mp[105][105];
int arr[105];
int main() {
  int ans = 1000000000;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    mp[u][v] = 1;
    mp[v][u] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      for (int k = j + 1; k <= n; k++) {
        if (mp[i][j] && mp[i][k] && mp[j][k]) {
          ans = min(ans, arr[i] + arr[j] + arr[k]);
        }
      }
    }
  }
  cout << (ans == 1000000000 ? -1 : ans) << endl;
  return 0;
}
