#include <bits/stdc++.h>
using namespace std;
int p[105][105], n, m, a[105], l, r, sum = 1e9;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l, &r);
    p[l][r] = 1;
    p[r][l] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      for (int k = j; k <= n; k++) {
        if (p[i][j] == 1 && p[j][k] == 1 && p[i][k] == 1) {
          sum = min(sum, a[i] + a[j] + a[k]);
        }
      }
    }
  }
  if (sum == 1e9)
    cout << "-1" << endl;
  else
    cout << sum << endl;
  return 0;
}
