#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100 + 10, big = 1000 * 1000 * 1000 + 10;
long long a[MAX_N];
long long mini = big;
bool check[MAX_N][MAX_N], hast = false;
int main() {
  int n, m, z, t;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> z >> t;
    check[z - 1][t - 1] = true;
    check[t - 1][z - 1] = true;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int t = 0; t < n; t++) {
        if (t == i || t == j) continue;
        if (check[i][j] == true && check[j][t] == true && check[t][i] == true) {
          hast = true;
          mini = min(a[i] + a[j] + a[t], mini);
        }
      }
    }
  }
  if (hast == true)
    cout << mini << endl;
  else
    cout << -1 << endl;
  return 0;
}
