#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int a[41], que[41];
vector<int> g[41];
int n, m, ans, cnt = 0;
bool vis[41], flag[41];
bool bfs(int s) {
  int l = 0, r = 0, x;
  que[0] = s;
  while (l <= r) {
    x = que[l++];
    if (x == n) return true;
    for (int y : g[x]) {
      if (vis[y]) continue;
      vis[y] = true;
      que[++r] = y;
    }
  }
  return false;
}
int calc(int x, int tot) {
  bool tmp[41];
  for (int i = 1; i <= n; ++i) tmp[i] = vis[i];
  bool ok = bfs(x);
  for (int i = 1; i <= n; ++i) vis[i] = tmp[i];
  if (!ok) return inf;
  if (!flag[n]) tot += a[n];
  for (int x : g[n])
    if (!flag[x]) tot += a[x];
  return tot;
}
void dfs(int x, int tot) {
  if (cnt >= 12000000) return;
  ++cnt;
  bool tmp[41];
  vis[x] = true;
  for (int i = 1; i <= n; ++i) tmp[i] = flag[i];
  if (!flag[x]) {
    flag[x] = true;
    tot += a[x];
  }
  for (int y : g[x])
    if (!flag[y]) {
      flag[y] = true;
      tot += a[y];
    }
  if (x == n) {
    ans = min(ans, tot);
    for (int i = 1; i <= n; ++i) flag[i] = tmp[i];
    vis[x] = false;
    return;
  }
  if (calc(x, tot) >= ans) {
    for (int i = 1; i <= n; ++i) flag[i] = tmp[i];
    vis[x] = false;
    return;
  }
  for (int y : g[x])
    if (!vis[y]) dfs(y, tot);
  for (int i = 1; i <= n; ++i) flag[i] = tmp[i];
  vis[x] = false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int x, y;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if (x == y) continue;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ans = inf;
  dfs(1, 0);
  printf("%d\n", ans);
  return 0;
}
