#include <bits/stdc++.h>
using namespace std;
const int maxn = 45;
const int maxm = maxn * maxn;
struct Edge {
  int y, nxt;
} edge[maxm];
struct Node {
  int x, cost;
  long long sta;
};
bool operator<(const Node &x, const Node &y) { return x.cost > y.cost; }
priority_queue<Node> Q;
int n, m, E_cnt;
int a[maxn], first[maxn];
void Ins(int x, int y) {
  edge[++E_cnt] = (Edge){y, first[x]};
  first[x] = E_cnt;
}
void Read() {
  int i, x, y;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    Ins(x, y);
    Ins(y, x);
  }
}
bool Get_pos(long long sta, int x) { return sta >> (x - 1) & 1; }
void Minn(int &x, int y) {
  if (y < x) x = y;
}
void Solve() {
  int x, k, y, cost;
  long long sta;
  Node node;
  Q.push((Node){1, a[1], 1});
  while (!Q.empty()) {
    node = Q.top();
    Q.pop();
    x = node.x;
    cost = node.cost;
    sta = node.sta;
    for (k = first[x]; y = edge[k].y, k; k = edge[k].nxt)
      if (!Get_pos(sta, y)) {
        cost += a[y];
        sta |= 1ll << (y - 1);
      }
    if (x == n) {
      printf("%d\n", cost);
      break;
    }
  }
}
int main() {
  Read();
  Solve();
}
