#include <bits/stdc++.h>
using namespace std;
bool A[105][105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    A[a][b] = A[b][a] = true;
  }
  int solve = -1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (A[i][j] && A[i][k] && A[j][k]) {
          int price = v[i] + v[j] + v[k];
          if (solve == -1)
            solve = price;
          else
            solve = min(solve, price);
        }
      }
    }
  }
  cout << solve << '\n';
  return 0;
}
