#include <bits/stdc++.h>
using namespace std;
int n, m, c[45], ans = 10000011;
bool vis[45];
bool in[45];
vector<int> e[45];
void dfs(int k, int cost) {
  in[k] = 1;
  queue<int> tmp;
  for (int i = 0, len = e[k].size(); i < len; ++i) {
    int to = e[k][i];
    if (!vis[to]) {
      tmp.push(to);
      vis[to] = 1;
      cost += c[to];
    }
  }
  if (k == n) {
    ans = min(ans, cost);
    while (!tmp.empty()) {
      vis[tmp.front()] = 0;
      tmp.pop();
    }
    in[k] = 0;
    return;
  }
  for (int i = 0, len = e[k].size(); i < len; ++i) {
    int to = e[k][i];
    if (!in[to]) dfs(to, cost);
  }
  while (!tmp.empty()) {
    vis[tmp.front()] = 0;
    tmp.pop();
  }
  in[k] = 0;
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vis[1] = 1;
  in[1] = 1;
  dfs(1, c[1]);
  cout << ans << endl;
}
