#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int p[maxn];
bool mat[maxn][maxn];
int comb[4];
int minsum;
void dfs(int *x, int k, int n, int r) {
  if (k == r + 1) {
    int a = x[1], b = x[2], c = x[3];
    if (mat[a][b] && mat[b][c] && mat[a][c]) {
      minsum = min(minsum, p[a] + p[b] + p[c]);
    }
    return;
  }
  for (int i = x[k - 1] + 1; i <= n; ++i) {
    x[k] = i;
    dfs(x, k + 1, n, r);
  }
}
int main() {
  comb[0] = 0;
  minsum = INT_MAX;
  for (int i = 0; i < maxn; ++i)
    for (int j = 0; j < maxn; ++j) mat[i][j] = false;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> p[i];
  int u, v;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    mat[u][v] = mat[v][u] = true;
  }
  dfs(comb, 1, n, 3);
  if (minsum < INT_MAX)
    cout << minsum << endl;
  else
    cout << "-1" << endl;
  return 0;
}
