#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, first, second, a[101][101] = {0}, price[101];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> price[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> first >> second;
    a[first][second] = a[second][first] = 1;
  }
  m = 2147483000;
  for (int i = 1; i < n - 1; i++) {
    for (int x = i + 1; x < n; x++)
      for (int y = x + 1; y <= n; y++)
        if (a[i][x] && a[x][y] && a[i][y])
          m = min(m, price[i - 1] + price[x - 1] + price[y - 1]);
  }
  if (m == 2147483000) m = -1;
  cout << m;
}
