#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int f[105][105], a[105];
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  while (m--) {
    int c, d;
    cin >> c >> d;
    f[c][d] = f[d][c] = 1;
  }
  int ans = maxn * 100;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j < i; ++j)
      for (int k = 1; k < j; ++k)
        if (f[i][j] && f[j][k] && f[k][i]) ans = min(ans, a[i] + a[j] + a[k]);
  if (ans == maxn * 100)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
