#include <bits/stdc++.h>
using namespace std;
bool match[110][110];
int price[110];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> price[i];
  while (m--) {
    int a, b;
    cin >> a >> b;
    match[a][b] = match[b][a] = 1;
  }
  int ans = 999999999;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (!match[i][j]) continue;
      for (int k = j + 1; k <= n; ++k) {
        if (!match[j][k] || !match[i][k]) continue;
        ans = min(ans, price[i] + price[j] + price[k]);
      }
    }
  }
  if (ans == 999999999)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}
