#include <bits/stdc++.h>
using namespace ::std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 40 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;
int n, m, cost[maxn], vis[maxn], d[maxn][maxn];
int ans;
void DFS(int u) {
  if (u == n) {
    int tmp = 0;
    int vv[maxn];
    memset(vv, 0, sizeof(vv));
    for (int i = 1; i <= n; i++) {
      if (vis[i]) {
        tmp += cost[i];
        for (int j = 1; j <= n; j++)
          if (d[i][j] && !vis[j] && !vv[j]) {
            tmp += cost[j];
            vv[j] = 1;
          }
      }
    }
    ans = min(tmp, ans);
    return;
  }
  for (int i = 2; i <= n; i++) {
    if (!vis[i] && d[u][i]) {
      vis[i] = 1;
      DFS(i);
      vis[i] = 0;
    }
  }
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    memset(d, 0, sizeof(d));
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) scanf("%d", &cost[i]);
    for (int i = 0; i < m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      d[x][y] = d[y][x] = 1;
    }
    vis[1] = 1;
    ans = inf;
    DFS(1);
    printf("%d\n", ans);
  }
}
