#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> n;
  cin >> m;
  int val[100];
  for (int i = 0; i < n; i++) {
    cin >> val[i];
  }
  int match[100][100] = {0};
  for (int i = 0; i < m; i++) {
    int p;
    int q;
    cin >> p;
    cin >> q;
    if (p > q) {
      int temp = p;
      p = q;
      q = temp;
    }
    match[p - 1][q - 1] = 1;
  }
  int min = INT_MAX;
  int flag = 0;
  int sum;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if ((match[i][j] == 1) && (match[j][k] == 1) && (match[i][k] == 1)) {
          sum = val[i] + val[j] + val[k];
          if (min > sum) min = sum;
          flag = 1;
        }
      }
    }
  }
  if (m < 3) {
    cout << "-1" << endl;
    return 0;
  }
  if (flag == 0) {
    cout << "-1" << endl;
  } else {
    cout << min << endl;
  }
  return 0;
}
