#include <bits/stdc++.h>
int main() {
  int n, l, i, j, k, min, prize[101], u, v;
  bool m[101][101];
  scanf("%d %d", &n, &l);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) m[i][j] = false;
  for (i = 1; i <= n; i++) scanf("%d", &prize[i]);
  for (i = 1; i <= l; i++) {
    scanf("%d %d", &u, &v);
    m[u][v] = m[v][u] = true;
  }
  min = -1;
  for (i = 1; i < n - 1; i++)
    for (j = i + 1; j < n; j++)
      for (k = j + 1; k <= n && m[i][j]; k++)
        if (m[i][k] && m[j][k]) {
          if (min == -1)
            min = prize[i] + prize[j] + prize[k];
          else if (min > prize[i] + prize[j] + prize[k])
            min = prize[i] + prize[j] + prize[k];
        }
  printf("%d\n", min);
  return 0;
}
