#include <bits/stdc++.h>
using namespace std;
const int Maxn = 110, Inf = 4e6;
int n, m, cost[Maxn];
bool mark[Maxn][Maxn];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    mark[a - 1][b - 1] = true;
    mark[b - 1][a - 1] = true;
  }
  int minn = Inf;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (mark[i][j] && mark[i][k] && mark[j][k])
          minn = min(minn, cost[i] + cost[j] + cost[k]);
      }
    }
  }
  if (minn == Inf)
    cout << -1;
  else
    cout << minn;
}
