#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int n, m, pirces, price[maxn];
set<int> ss[maxn];
bool check(int i, int j, int k) {
  if (!ss[i].count(j)) return false;
  if (!ss[j].count(k)) return false;
  if (!ss[k].count(i)) return false;
  return true;
}
int main() {
  while (scanf("%d %d", &n, &m) == 2) {
    int prices = -1;
    for (int i = 1; i <= n; i++) ss[i].clear();
    for (int i = 1; i <= n; i++) scanf("%d", price + i);
    int a, b;
    for (int i = 0; i < m; i++) {
      scanf("%d %d", &a, &b);
      ss[a].insert(b);
      ss[b].insert(a);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++)
          if (i != j && j != k && k != i) {
            if ((prices == -1) || (price[i] + price[j] + price[k] < prices)) {
              if (check(i, j, k)) prices = price[i] + price[j] + price[k];
            }
          }
      }
    }
    printf("%d\n", prices);
  }
  return 0;
}
