#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-6;
const int maxn = 1e3 + 5;
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int mp[45][45], vis[45], num[45], pre[45];
int ans = INF;
int n, k;
void dfs(int u, int sum) {
  if (sum > ans) return;
  if (u == n) {
    int tmp = u;
    int temp = sum;
    int tmpvis[45];
    for (int i = 1; i <= n; i++) tmpvis[i] = vis[i];
    while (pre[tmp] != -1) {
      for (int i = 2; i <= n; i++) {
        if (mp[tmp][i] && !tmpvis[i]) {
          temp += num[i];
          tmpvis[i] = 1;
        }
      }
      tmp = pre[tmp];
    }
    ans = min(ans, temp);
    return;
  }
  for (int i = 2; i <= n; i++) {
    if (!vis[i] && mp[u][i]) {
      vis[i] = 1;
      pre[i] = u;
      dfs(i, sum + num[i]);
      vis[i] = 0;
    }
  }
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  int u, v;
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &u, &v);
    mp[u][v] = mp[v][u] = 1;
  }
  pre[1] = -1, vis[1] = 1;
  dfs(1, num[1]);
  printf("%d\n", ans);
  return 0;
}
