#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<cctype>
#include <iomanip>
#include <string>
#include <sstream>
#include <functional>
#include <numeric>
#include <stack>
#include <climits>
#include <float.h>
#include<unordered_map>
#include <bitset>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>= b;i--)
#define sz(a) ((int)a.size())
#define all(c) c.begin(), c.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpii;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef long double ld;
template <class T> const T& max(const T& a, const T&b, const T&c) { return max(a, max(b, c)); }
template <class T> const T& min(const T& a, const T&b, const T&c) { return min(a, min(b, c)); }
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll poww(ll a, ll b) {
if (b == 0) return 1;
ll tmp = poww(a, b / 2);
return (b & 1 ? a * tmp * tmp : tmp * tmp);
}
ll sumOfDigs(string s) { ll sum = 0; for (int i = 0; i < s.length(); i++) sum += s[i] - '0'; return sum; }
ll sumOfDigs(ll n) { return (n < 10 ? n : n % 10 + sumOfDigs(n / 10)); }
string itos(ll i) { string s = ""; while (i) { s += char(i % 10 + '0'); i /= 10; } reverse(all(s)); return s; }
ll stoi(string &s) { ll tot = 0; for (int i = (int)s.length() - 1, j = 1; i >= 0; i--, j *= 10) { tot += j * (s[i] + '0'); } return tot; }
int months[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
using namespace std;
#define PI acos((ld)-1.0)
void t(){
#ifndef online_judge
freopen("test.txt", "r", stdin);
#endif
}
ll fact[1000 * 1000];
ll mod = 1e9 + 7;
ll modpower(ll x, ll y, ll p)
{
x %= mod;
if (!y) return 1;
ll res = 1;
if (y & 1) { res *= x; res %= p; }
ll z = modpower(x, y / 2, p);
z %= p;
z *= z;
z %= mod;
res *= z;
res %= p;
return res;
}
int n, m;
int c[1000], conn[1000][1000], val[1 << 18], dp[1 << 18], cnt[1 << 18];
int main(){
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> c[i];
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
a--, b--;
conn[a][b] = conn[b][a] = 1;
}
int N = n / 2;
for (int i = 0; i < (1 << N); i++) {
int cost = 0;
vi v;
for (int j = 0; j < N; j++) if (i & (1 << j)) { cost += c[j]; v.pb(j); }
int poss = 1;
for (int j = 0; j < v.size(); j++) for (int k = j + 1; k < v.size(); k++) if (conn[v[j]][v[k]]) { poss = 0; break; }
if (poss) val[i] = cost;
}
for (int i = 0; i < (1 << N); i++) {
for (int submask = i;; submask = (submask - 1) & i) {
if (dp[i] < val[submask]) { dp[i] = val[submask]; cnt[i] = 1; }
else if (dp[i] == val[submask]) { cnt[i]++; }
if (!submask) break;
}
}
int mxCost = 0, mxCnt = 0;
for (ll i = 0; i < (1ll << n); i += (1 << N)) {
int cost = 0;
vi v;
for (int j = N; j < n; j++) if (i & (1 << j)) { v.pb(j); cost += c[j]; }
int poss = 1;
for (int j = 0; j < v.size(); j++) for (int k = j + 1; k < v.size(); k++) if (conn[v[j]][v[k]]) { poss = 0; break; }
if (poss){
int mask = (1 << N) - 1;
for (int j = 0; j < v.size(); j++) {
for (int k = 0; k < N; k++) if (conn[k][v[j]]) mask = mask & ~(1 << k);
}
cost += dp[mask];
if (cost > mxCost) { mxCost = cost; mxC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