#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 101;
bool visited[N];
int prices[N];
vector<int> adj[N];
long long k = 0, price = 0;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) scanf("%d", &prices[i]);
  int x, y;
  while (m--) {
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  long long total = -1;
  for (int i = 1; i <= n; ++i) {
    int num1 = i;
    for (int j = 0; j < adj[num1].size(); ++j) {
      int num2 = adj[num1][j];
      for (int k = 0; k < adj[num2].size(); ++k) {
        int num3 = adj[num2][k];
        for (int u = 0; u < adj[num3].size(); ++u) {
          if (adj[num3][u] == num1) {
            price = prices[num1 - 1] + prices[num2 - 1] + prices[num3 - 1];
            total = min(total, price);
            if (total == -1) total = price;
          }
        }
      }
    }
  }
  cout << total;
  return 0;
}
