#include<bits/stdc++.h>
#define int long long
using namespace std;
 

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

int a[100005];
vector<vector<int> >adj;
vector<int>temp;
multiset<int>s[100005];
int vis[100004];
set<pair<int,int> >lol;
set<pair<int,int> >loda;

void dfs(int ver)
{
    vis[ver]=1;
    temp.push_back(ver);
    for(auto i:adj[ver])
    {
        if(!vis[i])
            dfs(i);
    }
}

vector<pair<int,int> >madar;

void merge(int x,int y)
{
    s[x].erase(s[x].begin());
    s[y].erase(s[y].begin());
    if(s[x].size()<s[y].size())
        swap(x,y);
    for(auto i:s[y])
        s[x].insert(i);
    if(s[x].size()==1)
    {
        auto j=s[x].begin();
        madar.push_back({*j,x});
        return ;
    }
    auto j=s[x].begin();
    int tot=0;
    tot+=*j;
    loda.insert({tot,x});
    j++;
    tot+=*j;
    lol.insert({tot,x});
}

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,m;

    cin>>n>>m;
    adj.resize(n+1);

    for(int i=1;i<=n;i++)   
    {
        cin>>a[i];
    }

    int x,y;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        x++;
        y++;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            temp.clear();
            dfs(i);
            for(auto j:temp)
            {
                s[i].insert(a[j]);
            }
            if(s[i].size()==1)
            {
                madar.push_back({a[i],i});
            }
            else
            {
                int tot=0;
                auto k=s[i].begin();
                tot+=*k;
                loda.insert({tot,i});
                k++;
                tot+=*k;
                lol.insert({tot,i});
            }            
        }
    }

    int ans=0;
    while (!lol.empty())
    {
        if(loda.size()>1)
        {
            auto j=loda.begin();
            if(j->second==lol.begin()->second)
                j++;

            ans+=j->first+*s[lol.begin()->second].begin();
            pair<int,int>p=*lol.begin();
            pair<int,int>pp=*j;
            lol.erase(lol.begin());
            loda.erase(j);
            int tt=*s[p.second].begin();
            loda.erase({tt,p.second});
            auto kk=s[pp.second].begin();
            tt=*kk;
            kk++;
            tt+=*kk;
            lol.erase({tt,pp.second});
            merge(p.second,pp.second);
        }
        else if(madar.size())
        {
            pair<int,int> p=*lol.begin();
            lol.erase(lol.begin());
            int tt=*s[p.second].begin();
            loda.erase({tt,p.second});
            int ind=p.second;
            ans+=*s[ind].begin();
            s[ind].erase(s[ind].begin());
            ans+=madar.back().first;
            madar.pop_back();
            if(s[ind].size()==1)
            {
                madar.push_back({*s[ind].begin(),ind});
            }
            else
            {
                auto j=s[ind].begin();
                int tot=0;
                tot+=*j;
                loda.insert({tot,ind});
                j++;
                tot+=*j;
                lol.insert({tot,ind});
            }            
        }

        else
        {
            break;
        }        
    }
    if(madar.size()>2)
    {
        cout<<"Impossible";
        return 0;
    }
    else if(madar.size()==2)
    {
        ans+=madar.back().first;
        madar.pop_back();
        ans+=madar.back().first;
    }
    cout<<ans;
    

}


Measured memory_bytes: 23936