#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
} e[45 * 45];
int n, m, cnt, ans;
int head[45], w[45], pr[45], vis[45];
void add(int x, int y) {
  e[++cnt].next = head[x], e[cnt].to = y;
  head[x] = cnt;
}
bool mark[45];
void calc(int sp) {
  memset(mark, 0, sizeof(mark));
  int x = sp, minn = w[sp];
  mark[sp] = 1;
  while (x != 0) {
    for (int j = head[x]; j; j = e[j].next)
      if (!mark[e[j].to]) minn += w[e[j].to], mark[e[j].to] = 1;
    x = pr[x];
  }
  if (minn < ans) ans = minn;
}
void dfs(int x) {
  if (x == n) {
    calc(n);
    return;
  }
  for (int i = head[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (!vis[y]) {
      vis[y] = 1;
      pr[y] = x;
      dfs(y);
      vis[y] = 0;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &w[i]);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d %d", &x, &y);
    add(x, y), add(y, x);
  }
  memset(vis, 0, sizeof(vis));
  pr[1] = 0;
  ans = 2e9;
  vis[1] = 1;
  dfs(1);
  printf("%d\n", ans);
  return 0;
}
