#include <bits/stdc++.h>
using namespace std;
bool f[501][501];
long long P[501];
int main(int argc, char *argv[]) {
  int N, M, i, u, v, k, l;
  cin >> N >> M;
  for (i = 1; i <= N; i++) cin >> P[i];
  for (i = 1; i <= N; i++)
    for (k = 1; k <= N; k++) f[i][k] = false;
  for (i = 1; i <= M; i++) {
    cin >> u >> v;
    f[u][v] = true;
    f[v][u] = true;
  }
  long long mini = (1 << 29);
  long long sum;
  for (int i = 1; i <= N - 2; i++) {
    for (int j = i + 1; j <= N - 1; j++) {
      for (int k = j + 1; k <= N; k++) {
        if (f[i][j] && f[j][k] && f[k][i]) {
          sum = P[i] + P[j] + P[k];
          if (sum < mini) mini = sum;
        }
      }
    }
  }
  if (mini != (1 << 29))
    cout << mini << endl;
  else
    cout << -1 << endl;
  return 0;
}
