#include <bits/stdc++.h>
using namespace std;
vector<int> G[45];
map<long long, bool> visit;
int dp[45], a[45];
int n, m;
void add(long long& x, int w) { x |= (1LL << w); }
int update(long long x) {
  int sum = 0;
  for (int i = 1; i <= n; i++)
    if (x & (1LL << i)) sum += a[i];
  return sum;
}
void dfs(int u, long long now) {
  visit[now] = true;
  int lena = G[u].size();
  for (int i = 0; i < lena; i++) {
    long long tmp = now;
    int v = G[u][i];
    int lenb = G[v].size();
    for (int j = 0; j < lenb; j++) {
      int w = G[v][j];
      add(tmp, w);
    }
    add(tmp, v);
    int tot = update(tmp);
    if (tot <= dp[v]) {
      dp[v] = tot;
      if (visit[tmp]) continue;
      dfs(v, tmp);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int j = 1; j <= m; j++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  memset(dp, 127, sizeof(dp));
  dfs(1, 1);
  printf("%d\n", dp[n]);
  return 0;
}
