#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, s, n, max = -1, m, x, y;
  int a[101], b[101][101] = {0};
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    b[x][y] = 1;
    b[y][x] = 1;
  }
  for (i = 1; i <= n - 2; i++) {
    for (j = i + 1; j <= n - 1; j++) {
      if (b[i][j] != 1) continue;
      for (k = j + 1; k <= n; k++) {
        if (b[i][k] != 1 || b[j][k] != 1) continue;
        s = a[i] + a[j] + a[k];
        if (max != -1) {
          if (s < max) max = s;
        } else
          max = s;
      }
    }
  }
  printf("%d", max);
  return 0;
}
