#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, logic, h[101][101];
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) h[i][j] = 0;
  }
  scanf("%d%d", &n, &m);
  vector<int> cost(n), answ;
  for (int i = 0; i < n; i++) scanf("%d", &cost[i]);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    h[x - 1][y - 1] = 1;
    h[y - 1][x - 1] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int g = j + 1; g < n; g++) {
        if (h[i][j] && h[j][g] && h[i][g])
          answ.push_back(cost[i] + cost[j] + cost[g]);
      }
    }
  }
  if (!answ.size())
    cout << -1;
  else {
    sort(answ.begin(), answ.end());
    cout << answ[0];
  }
  return 0;
}
