#include <bits/stdc++.h>
using namespace std;
int n, m, ans, ok, p;
const int N = 107;
vector<int> q;
int pr[N];
int e[N][N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p);
    pr[i + 1] = p;
  }
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    e[a][b] = 1;
    e[b][a] = 1;
  }
  ans = 4000006;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (!e[i][j] || i == j) {
        continue;
      }
      for (int k = 1; k <= n; k++) {
        if (k == i || k == j || !e[i][k] || !e[j][k]) {
          continue;
        }
        ans = min(ans, pr[i] + pr[j] + pr[k]);
        ok = 1;
      }
    }
  }
  if (!ok) {
    ans = -1;
  }
  printf("%d\n", ans);
  return 0;
}
