#include <bits/stdc++.h>
using namespace std;
const int maxn = 50;
int used[maxn], c[maxn], cn[maxn], n, m, s, t, ans = maxn * 200;
vector<int> G[50];
inline void add_edge(int f, int t) {
  G[f].push_back(t);
  G[t].push_back(f);
}
int dfs(int x, int cnt) {
  used[x] = 1;
  int sum = 0;
  for (int i = 0; i < G[x].size(); i++)
    if (!used[G[x][i]] && cn[G[x][i]] == -1) sum += c[G[x][i]], cn[G[x][i]] = x;
  if (x == n) {
    ans = min(ans, cnt + sum);
    used[x] = 0;
    for (int i = 1; i <= n; i++) cn[i] = (cn[i] == x ? -1 : cn[i]);
    return 0;
  }
  for (int i = 0; i < G[x].size(); i++) {
    int gt = G[x][i];
    if (!used[gt]) dfs(gt, cnt + sum);
  }
  used[x] = 0;
  for (int i = 1; i <= n; i++) cn[i] = (cn[i] == x ? -1 : cn[i]);
}
int main() {
  memset(cn, -1, sizeof(cn));
  scanf("%d%d", &n, &m), s = 1, t = n;
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1, a, b; i <= m; i++) {
    scanf("%d%d", &a, &b);
    add_edge(a, b);
  }
  cn[1] = 0;
  dfs(s, c[s]);
  cout << ans << endl;
  return 0;
}
