#include <bits/stdc++.h>
int a[105], map[105][105] = {0};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int i, j, k, x, y;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    map[x][y] = map[y][x] = 1;
  }
  int min = -1;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      for (k = j + 1; k <= n; k++) {
        if (map[i][j] && map[i][k] && map[j][k]) {
          if (min < 0 || min > a[i] + a[j] + a[k]) min = a[i] + a[j] + a[k];
        }
      }
    }
  }
  printf("%d\n", min);
  return 0;
}
