#include <bits/stdc++.h>
using namespace std;
int n, m, t[110][110] = {0}, p[110], x, y, sol;
int si(int i, int j, int k) {
  bool b = t[i][j] && t[i][k] && t[j][k];
  if (b)
    return p[i] + p[j] + p[k];
  else
    return -1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    x--, y--;
    t[x][y] = t[y][x] = 1;
  }
  sol = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) {
        int tmp = si(i, j, k);
        if (tmp < 0) continue;
        if (sol < 0 || tmp < sol) sol = tmp;
      }
  printf("%d", sol);
}
