#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, m, p, q;
  cin >> n >> m;
  int a[n + 1][n + 1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) a[i][j] = 0;
  }
  int b[101];
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> p >> q;
    a[p][q] = 1;
    a[q][p] = 1;
  }
  int mini = INT_MAX;
  for (int i = 1; i <= n - 2; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      for (int k = j + 1; k <= n; k++) {
        if (a[i][j] && a[j][k] && a[i][k]) mini = min(mini, b[i] + b[j] + b[k]);
      }
    }
  }
  if (mini == INT_MAX)
    cout << -1 << endl;
  else
    cout << mini << endl;
  return 0;
}
