#include <bits/stdc++.h>
using namespace std;
int n, m;
int c[52];
bool g[52][52];
long long mask[52];
unordered_map<long long, long long> visited;
int ans = 1e9;
int calc(long long m) {
  int ret = 0;
  for (int i = 0; i < (int)(n); i++)
    if ((m >> i) & 1) ret += c[i];
  return ret;
}
void dfs(long long m, int p) {
  for (int to = 0; to < (int)(n); to++)
    if (g[p][to]) {
      long long nm = m | mask[to];
      if (to == n - 1) {
        ans = min(ans, calc(nm));
        continue;
      }
      if ((visited[nm] >> to) & 1) continue;
      visited[nm] = visited[nm] | (1ll << to);
      dfs(nm, to);
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); i++) scanf("%d", c + i);
  for (int i = 0; i < (int)(m); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u][v] = g[v][u] = true;
  }
  for (int i = 0; i < (int)(n); i++) {
    long long m = 1ll << i;
    for (int j = 0; j < (int)(n); j++)
      if (g[i][j]) m = m | (1ll << j);
    mask[i] = m;
  }
  visited[mask[0]] |= (1ll << 0);
  dfs(mask[0], 0);
  printf("%d\n", ans);
  return 0;
}
