#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, b, c, sum = 0, flag = 0, ans = 1e9;
  int a[105], vis[105][105];
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> b >> c;
    vis[b][c] = 1;
    vis[c][b] = 1;
  }
  for (int i = 1; i <= n - 2; i++) {
    for (int j = i + 1; j <= n - 1; j++) {
      for (int k = j + 1; k <= n; k++)
        if (vis[i][j] && vis[j][k] && vis[k][i]) {
          sum = a[i] + a[j] + a[k];
          ans = min(ans, sum);
          flag = 1;
        }
    }
  }
  if (flag)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
