#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
long long adj[41];
int a[41], que[41];
int head[41], to[41 * 41], pre[41 * 41];
int n, m, ans, cnt = 0, e = 0;
void addedge(int x, int y) {
  to[e] = y;
  pre[e] = head[x];
  head[x] = e++;
}
bool bfs(int beg, long long s) {
  int l = 0, r = 0, x, y;
  que[0] = beg;
  while (l <= r) {
    x = que[l++];
    if (x == n - 1) return true;
    for (int i = head[x]; i != -1; i = pre[i]) {
      y = to[i];
      if ((s >> y) & 1) continue;
      s |= 1LL << y;
      que[++r] = y;
    }
  }
  return false;
}
int calc(int x, long long s1, long long s2) {
  if (!bfs(x, s1)) return inf;
  s2 |= adj[n - 1];
  int tot = 0;
  for (int i = 0; i < n; ++i)
    if ((s2 >> i) & 1) tot += a[i];
  return tot;
}
void dfs(int x, long long s1, long long s2) {
  if (x == n - 1) {
    ans = min(ans, calc(x, s1, s2));
    return;
  }
  if (calc(x, s1, s2) >= ans) return;
  for (int i = head[x]; i != -1; i = pre[i]) {
    int y = to[i];
    if ((s1 >> y) & 1) continue;
    dfs(y, s1 | (1LL << y), s2 | adj[y]);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    adj[i] = 1LL << i;
  }
  memset(head, -1, sizeof(head));
  int x, y;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    --x;
    --y;
    addedge(x, y);
    addedge(y, x);
    adj[x] |= 1LL << y;
    adj[y] |= 1LL << x;
  }
  ans = inf;
  dfs(0, 1, adj[0]);
  printf("%d\n", ans);
  return 0;
}
