#include <bits/stdc++.h>
using namespace std;
int main() {
  long m, n, i1, i2, i3, a[200][200], res = 3000001, b[200];
  cin >> n >> m;
  for (i1 = 1; i1 <= n; i1++) cin >> b[i1];
  for (i1 = 1; i1 <= m; i1++) {
    cin >> i2 >> i3;
    a[i3][i2] = 1;
    a[i2][i3] = 1;
  }
  for (i1 = 1; i1 <= n; i1++)
    for (i2 = i1 + 1; i2 <= n; i2++)
      for (i3 = i2 + 1; i3 <= n; i3++)
        if (a[i1][i2] == 1 && a[i2][i3] == 1 && a[i1][i3] == 1 &&
            res > b[i1] + b[i2] + b[i3])
          res = b[i1] + b[i2] + b[i3];
  if (res == 3000001) res = -1;
  cout << res << endl;
}
