#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int toInt(char xx) { return xx - '0'; }
char toChar(int xx) { return xx + '0'; }
bool isNum(char xx) { return ('0' <= xx && xx <= '9'); }
int n, m, u, v;
int a[200], hop[200][200];
int res = 2023456789;
void read() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    hop[u][v] = true;
    hop[v][u] = true;
  }
}
void init() {}
void solve() {
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      for (int k = j + 1; k <= n; ++k) {
        if (hop[i][j] && hop[i][k] && hop[j][k]) {
          res = min(res, a[i] + a[j] + a[k]);
        }
      }
    }
  }
  if (res < 2023456789)
    cout << res;
  else
    cout << -1;
}
int main() {
  read();
  init();
  solve();
}
