#include <bits/stdc++.h>
using namespace std;
int n, m, a[109], ans = 99999999;
int x, y, p[109][109];
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", &x, &y);
    p[x][y] = 1;
    p[y][x] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (p[i][j] == 1 && p[i][k] == 1 && p[j][k] == 1)
          ans = min(ans, a[i] + a[k] + a[j]);
      }
    }
  }
  if (ans == 99999999)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
