#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 1e9;
int son[50] = {0}, p[50][50], c[50];
bool walk[50], f[50];
void dfs(int x, int tot) {
  int now[50], num = 0;
  if (tot >= ans) return;
  if (x == n) {
    for (int i = 1; i <= son[n]; i++)
      if (!f[p[x][i]]) tot += c[p[x][i]];
    if (tot < ans) ans = tot;
    return;
  }
  for (int j = 1; j <= son[x]; j++)
    if (!f[p[x][j]]) {
      now[++num] = p[x][j];
      f[p[x][j]] = true;
      tot += c[p[x][j]];
    }
  for (int i = 1; i <= son[x]; i++)
    if (!walk[p[x][i]]) {
      walk[p[x][i]] = true;
      dfs(p[x][i], tot);
      walk[p[x][i]] = false;
    }
  for (int i = 1; i <= num; i++) f[now[i]] = false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  memset(walk, false, sizeof(walk));
  memset(f, false, sizeof(f));
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    son[u]++;
    p[u][son[u]] = v;
    son[v]++;
    p[v][son[v]] = u;
  }
  walk[1] = true;
  f[1] = true;
  dfs(1, c[1]);
  printf("%d\n", ans);
  return 0;
}
