#include <bits/stdc++.h>
using namespace std;
long long mask[41];
set<pair<long long, int> > used;
int n, m, a[41], ans, sum;
bool u[41];
void rec(long long zan, int cur, long long use) {
  if (cur == n - 1) {
    long long M = 0;
    int S = 0;
    for (int i = 0; i < n; i++)
      if (((use >> i) & 1LL)) M |= mask[i];
    for (int i = 0; i < n; i++)
      if (!((M >> i) & 1LL)) S += a[i];
    ans = max(ans, S);
    return;
  }
  if (used.find(make_pair(use, cur)) != used.end()) return;
  used.insert(make_pair(use, cur));
  for (int i = 0; i < n; i++) {
    if (!((mask[cur] >> i) & 1LL)) continue;
    if (!((zan >> i) & 1LL)) continue;
    long long go = zan - (zan & mask[cur]);
    go += (1LL << i);
    rec(go, i, use | (1LL << i));
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> 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 (u[q]) continue;
    u[q] = 1;
    sum += a[q];
    for (int i = 0; i < n; i++)
      if (((mask[q] >> i) & 1LL) == 1LL && !u[i]) {
        que.push(i);
      }
  }
  long long beg = 0;
  for (int i = 0; i < n; i++)
    if (u[i]) beg += 1LL << i;
  rec(beg, 0, 1);
  cout << sum - ans << endl;
}
