#include <bits/stdc++.h>
using namespace std;
int val[45];
vector<int> s[45];
struct P {
  int pt, cost;
  long long int mask;
};
int dis[45];
set<pair<int, long long int> > is;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &val[i]);
    dis[i] = 2147483647;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    s[x].push_back(y);
    s[y].push_back(x);
  }
  queue<P> que;
  P in;
  in.pt = 0;
  in.cost = val[0];
  in.mask = 1;
  for (int i = 0; i < s[0].size(); i++) {
    in.mask |= (1LL << s[0][i]);
    in.cost += val[s[0][i]];
  }
  is.insert(make_pair(0, in.mask));
  dis[0] = in.cost;
  que.push(in);
  while (que.size()) {
    P out = que.front();
    que.pop();
    is.erase(make_pair(out.pt, out.mask));
    for (int j = 0; j < s[out.pt].size(); j++) {
      int u = s[out.pt][j];
      in.pt = u;
      in.cost = out.cost;
      in.mask = out.mask;
      for (int k = 0; k < s[u].size(); k++) {
        int v = s[u][k];
        if (in.mask & (1LL << v)) continue;
        in.mask |= (1LL << v);
        in.cost += val[v];
      }
      if (in.cost <= dis[u]) {
        dis[u] = in.cost;
        if (is.find(make_pair(in.pt, in.mask)) != is.end()) continue;
        is.insert(make_pair(in.pt, in.mask));
        que.push(in);
      }
    }
  }
  printf("%d\n", dis[n - 1]);
}
