#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int a = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c) && c != EOF) {
    if (c == '-') f = 1;
    c = getchar();
  }
  if (c == EOF) exit(0);
  while (isdigit(c)) {
    a = (a << 3) + (a << 1) + (c ^ '0');
    c = getchar();
  }
  return f ? -a : a;
}
map<pair<int, long long>, int> dp;
int N, M, ans, head[41], val[41], cntEd;
struct Edge {
  int end, upEd;
} Ed[2010];
long long fj[41];
priority_queue<pair<int, pair<int, long long> > > q;
inline void addEd(int a, int b) {
  Ed[++cntEd].end = b;
  Ed[cntEd].upEd = head[a];
  head[a] = cntEd;
  fj[a] += 1ll << b;
}
void Dijk() {
  int all = 0;
  for (int i = 0; i < N; ++i)
    if (fj[0] & (1 << i)) all += val[i];
  dp.clear();
  dp[pair<int, long long>(0, fj[0])] = all;
  q.push(
      pair<int, pair<int, long long> >(-all, pair<int, long long>(0, fj[0])));
  while (!q.empty()) {
    pair<int, pair<int, long long> > t = q.top();
    q.pop();
    if (-t.first > dp[t.second]) continue;
    int x = t.second.first, cost = dp[t.second];
    long long y = t.second.second;
    if (x == N - 1) {
      ans = min(ans, cost);
      continue;
    }
    for (int i = head[x]; i; i = Ed[i].upEd) {
      long long k = y | fj[Ed[i].end];
      int c = cost;
      for (int j = 0; j < N; ++j)
        if (!(y & (1 << j)) && (k & (1 << j))) c += val[j];
      if (!dp.count(pair<int, long long>(Ed[i].end, k)) ||
          dp[pair<int, long long>(Ed[i].end, k)] > c) {
        dp[pair<int, long long>(Ed[i].end, k)] = c;
        q.push(pair<int, pair<int, long long> >(
            -c, pair<int, long long>(Ed[i].end, k)));
      }
    }
  }
}
int main() {
  while (1) {
    N = read();
    M = read();
    ans = 1e9;
    for (int i = 0; i < N; ++i) val[i] = read();
    cntEd = 0;
    memset(head, 0, sizeof(head));
    memset(fj, 0, sizeof(fj));
    for (int i = 0; i < N; ++i) fj[i] = 1ll << i;
    for (int i = 1; i <= M; ++i) {
      int a = read() - 1, b = read() - 1;
      addEd(a, b);
      addEd(b, a);
    }
    Dijk();
    printf("%d\n", ans);
  }
  return 0;
}
