#include <bits/stdc++.h>
using namespace std;
const int MAXN = 45;
int n, m;
int weight[MAXN];
int map[MAXN][MAXN];
int vis[MAXN];
int maxn = 0;
int visflag[MAXN];
int visnode[MAXN][MAXN];
int ans = 0x3f3f3f3f;
int passvalue[MAXN];
vector<int> visvec[MAXN];
void dfs(int s, int t, int temp) {
  if (s == 1 && t == n) {
    for (int i = 1; i <= n; i++) {
      if (map[1][i] == 1 || map[n][i] == 1) {
        vis[i] = 1;
        temp += weight[i];
      }
    }
    vis[s] = 1;
    temp += weight[s];
    vis[t] = 1;
    temp += weight[t];
  }
  if (s == t) {
    ans = min(ans, temp);
    return;
  }
  if (temp >= ans) {
    return;
  }
  if (temp >= maxn) {
    ans = maxn;
    return;
  }
  if (temp > passvalue[s]) return;
  for (int i = 1; i <= n; i++) {
    if (map[s][i] && !visnode[s][i] && visflag[i] == 0) {
      visflag[i] = 1;
      visnode[s][i] = 1;
      visnode[i][s] = 1;
      if (vis[i] == 0) {
        temp += weight[i];
        visvec[i].push_back(i);
        vis[i] = 1;
      }
      for (int j = 1; j <= n; j++) {
        if (vis[j] == 0 && map[i][j]) {
          temp += weight[j];
          vis[j] = 1;
          visvec[i].push_back(j);
        }
      }
      passvalue[s] = min(temp, passvalue[s]);
      dfs(i, t, temp);
      visflag[i] = 0;
      visnode[s][i] = 0;
      visnode[i][s] = 0;
      for (int j = 0; j < visvec[i].size(); j++) {
        int t = visvec[i][j];
        temp -= weight[t];
        vis[t] = 0;
      }
      visvec[i].clear();
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(weight, 0, sizeof(weight));
  ans = 0;
  memset(map, 0, sizeof(map));
  memset(vis, 0, sizeof(vis));
  memset(visnode, 0, sizeof(visnode));
  maxn = 0;
  memset(visflag, 0, sizeof(visflag));
  for (int i = 0; i < MAXN; i++) passvalue[i] = INT_MAX;
  ans = 0x3f3f3f3f;
  for (int i = 0; i < MAXN; i++) visvec[i].clear();
  for (int i = 1; i <= n; i++) scanf("%d", &weight[i]);
  for (int i = 1; i <= n; i++) {
    maxn += weight[i];
  }
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    map[a][b] = 1;
    map[b][a] = 1;
  }
  int temp = 0;
  dfs(1, n, temp);
  printf("%d\n", ans);
}
