#include <bits/stdc++.h>
using namespace std;
int A[110];
bool M[110][110];
int main() {
  ios::sync_with_stdio(false);
  int n;
  int m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    M[u][v] = M[v][u] = 1;
  }
  int ans = -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 (M[i][j] and M[j][k] and M[i][k]) {
          int val = A[i] + A[j] + A[k];
          if (ans == -1 or ans > val) ans = val;
        }
      }
    }
  }
  cout << ans << endl;
}
