#include <bits/stdc++.h>
using namespace std;
const int N = 45;
const int inf = 1e9;
int n, m, ans;
vector<int> e[N];
int per[N];
bool vis[N];
bool cd[N];
void dfs(int p, int tans) {
  vis[p] = true;
  vector<int> torec;
  torec.clear();
  for (auto v : e[p])
    if (!cd[v]) {
      tans += per[v];
      cd[v] = true;
      torec.push_back(v);
    }
  if (tans > ans) return;
  if (p == n) {
    ans = tans;
    vis[p] = false;
    for (auto v : torec) cd[v] = false;
    return;
  }
  for (auto v : e[p])
    if (!vis[v]) dfs(v, tans);
  vis[p] = false;
  for (auto v : torec) cd[v] = false;
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &per[i]);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  ans = inf;
  memset(vis, 0, sizeof(vis));
  memset(cd, 0, sizeof(cd));
  cd[1] = 1;
  dfs(1, per[1]);
  printf("%d\n", ans);
  return 0;
}
