#include <bits/stdc++.h>
using namespace std;
bool match[105][105];
int price[105];
int main() {
  int n, m, u, v, a, b, c, mini = 1000000000;
  cin >> n >> m;
  memset(match, false, sizeof match);
  for (int i = 0; i < n; i++) cin >> price[i];
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    match[u][v] = true;
    match[v][u] = true;
  }
  bool find = false;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++) {
        if (match[i][j] && match[j][k] && match[i][k]) {
          if (price[i] + price[j] + price[k] < mini) {
            mini = price[i] + price[j] + price[k];
            find = true;
          }
        }
      }
  if (!find)
    cout << -1;
  else
    cout << mini;
  return 0;
}
