#include <bits/stdc++.h>
using namespace std;
bool vis[45], in[45], can[45];
int ans, n, m, c[45];
int pre[200], last[45], other[200], L;
void add(int u, int v) {
  L++;
  pre[L] = last[u];
  last[u] = L;
  other[L] = v;
}
void dfs(int v, int cost, int prep) {
  queue<int> q;
  queue<int> qq;
  in[v] = 1;
  vis[v] = 1;
  can[prep] = 1;
  bool ar = 0;
  for (int p = last[prep]; p; p = pre[p]) {
    int u = other[p];
    if (!can[u]) {
      can[u] = 1;
      qq.push(u);
    }
  }
  for (int p = last[v]; p; p = pre[p]) {
    int u = other[p];
    if (!vis[u]) {
      vis[u] = 1;
      cost += c[u];
      q.push(u);
    }
  }
  if (cost > ans) {
    while (!q.empty()) {
      vis[q.front()] = 0;
      q.pop();
    }
    while (!qq.empty()) {
      can[qq.front()] = 0;
      qq.pop();
    }
    in[v] = 0;
    can[prep] = 1;
    vis[v] = 0;
    return;
  }
  if (v == n) {
    ans = cost;
    while (!q.empty()) {
      vis[q.front()] = 0;
      q.pop();
    }
    while (!qq.empty()) {
      can[qq.front()] = 0;
      qq.pop();
    }
    in[v] = 0;
    can[prep] = 0;
    vis[v] = 0;
    return;
  }
  for (int p = last[v]; p; p = pre[p]) {
    int u = other[p];
    if (!in[u] && !can[u]) dfs(u, cost, v);
  }
  while (!q.empty()) {
    vis[q.front()] = 0;
    q.pop();
  }
  in[v] = 0;
  vis[v] = 0;
  while (!qq.empty()) {
    can[qq.front()] = 0;
    qq.pop();
  }
  in[v] = 0;
  can[prep] = 0;
  vis[v] = 0;
}
int main() {
  ans = 1e9;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", c + i);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  dfs(1, c[1], 0);
  printf("%d\n", ans);
}
