#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mp;
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) {
    return (mp[a] < mp[b] || (mp[a] == mp[b] && a < b));
  }
};
set<pair<int, int>, cmp> st;
long long d[50];
int ans, A[50], n, m;
void dijkstra() {
  st.insert(make_pair(d[0] | 1LL, 0));
  int js = A[0];
  for (int i = 1; i < n; i++) {
    if ((d[0] >> i) & 1LL) js += A[i];
  }
  mp[make_pair(d[0] | 1LL, 0)] = js;
  while (true) {
    pair<int, int> U;
    U = *st.begin();
    st.erase(st.begin());
    int u = U.second;
    int val = mp[U];
    if (u == n - 1) {
      ans = val;
      break;
    }
    for (int v = 0; v < n; v++) {
      if (!((d[u] >> v) & 1LL)) continue;
      long long nex = U.first | d[v];
      long long dif = nex ^ U.first;
      int val_ = val;
      for (int k = 0; k < n; k++) {
        if ((dif >> k) & 1LL) val_ += A[k];
      }
      pair<int, int> V = make_pair(nex, v);
      if (!mp[V]) {
        mp[V] = val_;
        st.insert(V);
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    d[a] |= (1LL << b);
    d[b] |= (1LL << a);
  }
  dijkstra();
  printf("%d\n", ans);
  return 0;
}
