#include <bits/stdc++.h>
using namespace std;
const int N = 50, inf = 1 << 29;
int n, m, ans = 1 << 29;
vector<int> G[N];
set<long long> s[N];
int a[N], mn[N];
void dfs(int u, int sum, long long mask, long long vis) {
  if (s[u].find(vis) != s[u].end()) return;
  s[u].insert(vis);
  vis ^= (1ll << u);
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i], t = sum;
    long long S = mask;
    for (int j = 0; j < G[v].size(); ++j) {
      int k = G[v][j];
      if (!(S & (1ll << k))) {
        S |= (1ll << k);
        t += a[k];
      }
    }
    if (t <= mn[v]) {
      mn[v] = t;
      dfs(v, t, S, vis);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(mn, 0x3f3f, sizeof(mn));
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    G[i].clear();
    s[i].clear();
  }
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  G[0].push_back(1);
  dfs(0, 0, 0, 0);
  printf("%d\n", mn[n]);
  return 0;
}
