#include <bits/stdc++.h>
int sum, flag[105], n, m, a, b, A[105], map[105][105];
void dfs(int last_last, int last) {
  int S;
  flag[last] = 1;
  for (int i = 1; i <= n; i++) {
    if (flag[i] || !map[last][i]) continue;
    if (map[i][last_last]) {
      S = A[i] + A[last] + A[last_last];
      if (S < sum) sum = S;
    }
    dfs(last, i);
    flag[i] = 0;
  }
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(flag, 0, sizeof(flag));
    memset(map, 0, sizeof(map));
    for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &a, &b);
      map[a][b] = 1;
      map[b][a] = 1;
    }
    sum = 99999999;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (i == j || !map[i][j]) continue;
        for (int k = 1; k <= n; k++) {
          if (i == k || j == k) continue;
          if (map[k][j] && map[i][k])
            if (A[i] + A[k] + A[j] < sum) sum = A[i] + A[k] + A[j];
        }
      }
    if (sum == 99999999)
      printf("-1\n");
    else
      printf("%d\n", sum);
  }
  return 0;
}
