#include <bits/stdc++.h>
using namespace std;
int main() {
  int pc[105], match[100][100] = {0};
  int n, m, i, a, b, j, k, flag = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> pc[i];
  while (m--) {
    cin >> a >> b;
    match[a - 1][b - 1] = 1;
    match[b - 1][a - 1] = 1;
  }
  int min = 1000000000;
  for (i = 0; i < n; i++)
    for (j = i + 1; j < n; j++)
      for (k = j + 1; k < n; k++)
        if (match[i][j] && match[j][k] && match[i][k] &&
            (pc[i] + pc[j] + pc[k] < min)) {
          min = pc[i] + pc[j] + pc[k];
          flag = 1;
        }
  if (flag)
    cout << min << endl;
  else
    cout << "-1" << endl;
}
