#include <bits/stdc++.h>
using namespace std;
const double pi = 2.0 * acos(0.0);
const double eps = 1.0e-9;
const int dr[] = {-1, 0, 1, 0}, dc[] = {0, 1, 0, -1};
const int dr6[] = {1, 1, 0, -1, -1, 0}, dc6[] = {0, 1, 1, 0, -1, -1};
const int dr8[] = {-1, -1, 0, 1, 1, 1, 0, -1},
          dc8[] = {0, 1, 1, 1, 0, -1, -1, -1};
int main(void) {
  int kase = 1000000000;
  for (int ks = 1, n, m; ks <= kase && 2 == scanf("%d %d", &n, &m); ++ks) {
    int p[128];
    bool g[128][128] = {{false}};
    for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
    for (int i = 0, x, y; i < m && 2 == scanf("%d %d", &x, &y); ++i)
      g[x][y] = g[y][x] = true;
    int t = 1000000000;
    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]) t = min(t, p[i] + p[j] + p[k]);
    printf("%d\n", t < 1000000000 ? t : -1);
    break;
  }
  return 0;
}
