#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, graph[N][N], ai[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = (0); (i) <= (n - 1); ++(i)) scanf("%d", ai + i);
  for (int(i) = (1); (i) <= (m); ++(i)) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    graph[u][v] = graph[v][u] = 1;
  }
  int ans = INT_MAX;
  for (int(i) = (0); (i) <= (n - 1); ++(i))
    for (int(j) = (0); (j) <= (n - 1); ++(j))
      if (graph[i][j])
        for (int(k) = (j + 1); (k) <= (n - 1); ++(k))
          if (graph[i][k] && graph[j][k]) {
            ans = min(ans, ai[i] + ai[j] + ai[k]);
          }
  printf("%d\n", ans == INT_MAX ? -1 : ans);
  return 0;
}
