#include <bits/stdc++.h>
using namespace std;
int g[150][150];
int price[150];
int n, m;
int ans;
int flody() {
  ans = 1 << 29;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      for (int k = j + 1; k <= n; k++)
        if (g[i][j] && g[j][k] && g[k][i]) {
          ans = min(ans, price[i] + price[j] + price[k]);
        }
  return ans;
}
int main() {
  int u, v;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(g, 0, sizeof(g));
    memset(price, 0, sizeof(price));
    for (int i = 1; i <= n; i++) scanf("%d", &price[i]);
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      g[u][v] = g[v][u] = 1;
    }
    if (flody() == 1 << 29)
      printf("-1\n");
    else
      printf("%d\n", flody());
  }
  return 0;
}
