#include<bits/stdc++.h>
using namespace std;
struct node
{
  int cost,p;
  long long sta;
  bool operator < (node b)const
  {
    return cost>b.cost;
  }
};
priority_queue<node> Q;
int n,m,c[50],ans;
vector<int> g[50];
map<long long,int> mp;
void dijkstra()
{
  Q.push((node){c[1],1,1});
  while(!Q.empty())
  {
    node x=Q.top();Q.pop();
    if(mp[x.sta]<x.cost&&mp[x.sta]) continue;
    mp[x.sta]=x.cost;
    if(x.sta&(1<<(n-1)))
    {
      ans=x.cost;
      return;
    }
    long long newst=0,newco=0;
    for(int i=0;i<g[x.p].size();i++)
    {
      int v=g[x.p][i];
      if((1<<(v-1))&x.sta) continue;
      newst|=(1<<(v-1));newco+=c[v];
    }
    for(int i=0;i<g[x.p].size();i++)
    {
      int v=g[x.p][i];
      if((1<<(v-1))&x.sta) continue;
      node newv=(node){x.cost+newco,v,newst|x.sta};
      Q.push(newv);
    }
  }
}
int main()
{
  //freopen("I.in","r",stdin);
  //freopen("I.out","w",stdout);
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++) scanf("%d",&c[i]);
  for(int i=1;i<=m;i++)
  {
    int x,y;scanf("%d%d",&x,&y);
    g[x].push_back(y);g[y].push_back(x);
  }
  dijkstra();
  cout<<ans<<endl;
  return 0;
}