#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
ll adj[40];
int c[40];
int dfs(int k, ll f) {
  if (k == n - 1) {
    int cost = 0;
    for (int i = 0; i < n; ++i)
      if (~f >> i & 1) cost += c[i];
    return cost;
  }
  int mincost = 1000000;
  for (int i = 0; i < n; ++i) {
    if ((adj[k] >> i & 1) & (f >> i & 1)) {
      int res = dfs(i, ~adj[k] & f);
      if (res < mincost) mincost = res;
    }
  }
  return mincost;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i) adj[i] = 0;
  for (int i = 0; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u] |= 1 << v;
    adj[v] |= 1 << u;
  }
  cout << dfs(0, ~1) << endl;
  return 0;
}
