#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
int mem[1010][15];
int n, m, a[15], b[15], c[15], d[15];
int dp(int rem, int curr) {
  if (curr == m + 1) return 0;
  if (mem[rem][curr] != -1) return mem[rem][curr];
  int ret = 0;
  for (int i = 0; i * c[curr] <= rem && i * b[curr] <= a[curr]; i++) {
    ret = max(ret, dp(rem - i * c[curr], curr + 1) + d[curr] * i);
  }
  return mem[rem][curr] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, price[110];
  bool mat[110][110];
  memset(mat, 0, sizeof(mat));
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) cin >> price[i];
  int a, b;
  for (int i = 0; i < (int)(m); i++)
    cin >> a >> b, mat[a - 1][b - 1] = mat[b - 1][a - 1] = true;
  int ans = oo;
  for (int i = 0; i < (int)(n); i++)
    for (int k = 0; k < (int)(n); k++)
      for (int j = 0; j < (int)(n); j++) {
        if (mat[i][k] && mat[i][j] && mat[k][j])
          ans = min(ans, price[i] + price[j] + price[k]);
      }
  cout << (ans == oo ? -1 : ans) << endl;
  return 0;
}
