#include <bits/stdc++.h>
using namespace std;
int val[45];
long long int use[45];
vector<int> s[45];
int ans = 1 << 30;
int n, m;
int is[45];
int cnt(long long int mask) {
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    if (mask & (1 << i)) tmp += val[i];
  }
  return tmp;
}
void dfs(int u, long long int mask) {
  if (u == n - 1) {
    ans = min(ans, cnt(mask));
    return;
  }
  for (int i = 0; i < s[u].size(); i++) {
    int v = s[u][i];
    if (is[v]) continue;
    is[v] = 1;
    dfs(v, mask | use[v]);
    is[v] = 0;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &val[i]);
    use[i] = (1 << i);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    s[x].push_back(y);
    s[y].push_back(x);
    use[x] |= (1LL << y);
    use[y] |= (1LL << x);
  }
  is[0] = 1;
  dfs(0, use[0]);
  printf("%d\n", ans);
}
