#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-6;
const long double pi = acos(-1.0);
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
    dy[] = {1, 0, -1, 0, 1, -1, 1, -1, 0};
int a[100];
int match[100][100];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  for (int i = 0; i < (int)(m); ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    match[u][v] = match[v][u] = true;
  }
  int ans = -1;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(i); ++j)
      if (match[j][i]) {
        for (int k = 0; k < (int)(j); ++k)
          if (match[k][j] && match[k][i]) {
            if (ans == -1)
              ans = a[i] + a[j] + a[k];
            else
              ans = min(a[i] + a[j] + a[k], ans);
          }
      }
  cout << ans << endl;
}
