#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const int M = N * N;
int n, m, mi;
int head[N], point[N];
int vis[N];
struct edges {
  int to, next;
} e[M << 1];
void add(int u, int v) {
  e[++mi] = (edges){v, head[u]};
  head[u] = mi;
}
int dfs(int u, int step) {
  if (u == n) return 0;
  int ans = (int)1e9;
  for (int p = head[u]; p; p = e[p].next)
    if (vis[e[p].to] == 0) {
      vis[e[p].to] = step;
    }
  for (int p = head[u]; p; p = e[p].next)
    if (vis[e[p].to] == step) {
      ans = min(ans, dfs(e[p].to, step + 1));
    }
  for (int p = head[u]; p; p = e[p].next)
    if (vis[e[p].to] == step) {
      ans += point[e[p].to];
      vis[e[p].to] = 0;
    }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &point[i]);
  }
  int u, v;
  while (m--) {
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  int ans = dfs(1, 1);
  printf("%d\n", ans);
}
