#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const int M = N * N;
inline void read(int &p) {
  char c = getchar();
  while (c < 48 || c > 57) {
    c = getchar();
  }
  p = 0;
  while (c > 47 && c < 58) {
    p = p * 10 + c - 48;
    c = getchar();
  }
}
int buf[66];
inline void write(int p) {
  if (!p) {
    putchar(48);
  } else {
    if (p < 0) {
      putchar('-');
      p = -p;
    }
    int t = 0;
    for (; p; p /= 10) {
      buf[++t] = p % 10;
    }
    for (; t; t--) {
      putchar(buf[t] + 48);
    }
  }
}
int first[N];
int v[M << 1], nxt[M << 1];
int tot;
inline void add(const int &U, const int &V) {
  ++tot;
  v[tot] = V;
  nxt[tot] = first[U];
  first[U] = tot;
}
int w[N];
int n, m;
int ans = 0x3f3f3f3f;
int b[N];
int q[N];
void dfs(int k, const int &al) {
  int adj = 0;
  int head = 0;
  for (int j = first[k]; j; j = nxt[j]) {
    if (b[v[j]]) {
      continue;
    }
    adj += w[v[j]];
    q[++head] = v[j];
    b[v[j]] = true;
  }
  if (k == n) {
    ans = min(ans, adj + al);
  }
  for (int i = 1; i <= head; i++) {
    dfs(q[i], al + adj);
  }
  for (int i = 1; i <= head; i++) {
    b[q[i]] = false;
  }
  return;
}
int main(void) {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) {
    read(w[i]);
  }
  int f, t;
  for (int i = 1; i <= m; i++) {
    read(f);
    read(t);
    add(t, f);
    add(f, t);
  }
  b[1] = true;
  dfs(1, w[1]);
  write(ans);
  putchar('\n');
  return 0;
}
