#include <bits/stdc++.h>
using namespace std;
long long mask[41];
unordered_set<long long> used;
int n, m, a[41], ans, sum;
bool u[41], usedd[41];
double x;
bool ok(long long M) {
  if (clock() - x > 2.8 * CLOCKS_PER_SEC) return 0;
  long long cur = 1;
  bool uu[41] = {};
  while (((cur >> (n - 1)) & 1LL) == 0LL) {
    long long dif = cur;
    for (int i = 0; i < 41; i++) {
      if (uu[i] || ((cur >> i) & 1LL) == 0LL) continue;
      uu[i] = 1;
      cur |= (mask[i] & M);
    }
    if (cur == dif) return 0;
  }
  return 1;
}
void rec(long long M) {
  if (clock() - x > 2.8 * CLOCKS_PER_SEC) return;
  if (used.find(M) != used.end()) return;
  used.insert(M);
  int val = 0;
  for (int i = 0; i < n; i++)
    if ((mask[i] & M) == 0LL) val += a[i];
  ans = max(ans, val);
  int a[41];
  for (int i = 0; i < n; i++) a[i] = i;
  random_shuffle(a, a + n);
  for (int ii = 0; ii < n; ii++) {
    int i = a[ii];
    if ((mask[i] & M) == 0LL) continue;
    long long MM = M - (mask[i] & M);
    if (((MM >> 0) & 1LL) == 0LL || ((MM >> (n - 1)) & 1LL) == 0LL) continue;
    if (ok(MM)) rec(MM);
  }
}
int main() {
  x = clock();
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    mask[i] = 1LL << i;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    mask[a] |= 1LL << b;
    mask[b] |= 1LL << a;
  }
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int q = que.front();
    que.pop();
    if (usedd[q]) continue;
    usedd[q] = 1;
    for (int i = 0; i < n; i++)
      if (((mask[q] >> i) & 1LL) == 1LL && !usedd[i]) {
        que.push(i);
      }
  }
  long long beg = 0;
  for (int i = 0; i < n; i++)
    if (usedd[i]) beg += 1LL << i;
  rec(beg);
  cout << sum - ans << endl;
}
