#include <bits/stdc++.h>
using namespace std;
int a[105];
bool b[105][105];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    b[u][v] = b[v][u] = true;
  }
  int ans = -1;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++)
        if (b[i][j] && b[i][k] && b[j][k]) {
          if (ans == -1 || a[i] + a[j] + a[k] < ans) ans = a[i] + a[j] + a[k];
        }
  cout << ans << endl;
  return 0;
}
