#include <iostream>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <math.h>
#define MODD 1000000007
#define MAXN 120000
#define ll long long
using namespace std;

vector<int> edges[MAXN+2];

int A[MAXN+2];
int comp[MAXN+2];
vector<int> comp_to_val[MAXN+2];
void dfs(int x,int cid) {
    if (comp[x] != -1)
        return;
    comp[x]=cid;
    for(int y : edges[x]) {
        dfs(y,cid);
    }
}

/*
int parent[MAXN+2];
int rankk[MAXN+2];
int sizes[MAXN+2];
int numleft[MAXN+2];
int A[MAXN+2];

set<pair<int,int>> values[MAXN+2];

int Find(int x) {
    if (parent[x] != x) {
        parent[x]=Find(parent[x]);
    }
    return parent[x];
}

int GetSize(int x) {
    return sizes[Find(x)];
}

ll ans;

void UnionSets(int id1,int id2) {
    
    if (!values[id1].empty()) {
        ans += values[id1].begin()->first;
        values[id1].erase(values[id1].begin());
    }
    
    if (!values[id2].empty()) {
        ans += values[id2].begin()->first;
        values[id2].erase(values[id2].begin());
    }
    
    for(auto x : values[id1])
        values[id2].insert(x);
    
    
    
    
}

bool Union(int x,int y) {
    int xRoot=Find(x);
    int yRoot=Find(y);
    if (xRoot==yRoot)
        return false;
    
    
    if (rankk[xRoot]<rankk[yRoot]) {
        parent[xRoot]=yRoot;
        sizes[yRoot] += sizes[xRoot];
        numleft[yRoot] = numleft[yRoot]-1+numleft[xRoot]-1;
        
        UnionSets(xRoot, yRoot);
        
    } else if (rankk[xRoot]>rankk[yRoot]) {
        parent[yRoot]=xRoot;
        sizes[xRoot] += sizes[yRoot];
        numleft[xRoot] = numleft[xRoot]-1+numleft[yRoot]-1;
        UnionSets(yRoot, xRoot);

    } else {
        parent[yRoot]=xRoot;
        sizes[xRoot] += sizes[yRoot];
        numleft[xRoot] = numleft[xRoot]-1+numleft[yRoot]-1;

        rankk[xRoot]++;
        UnionSets(yRoot, xRoot);

    }
    return true;
}

*/



int main() {
    int N,M;
    cin>>N>>M;
    
    
    for(int i=0;i<N;i++) {
        cin>>A[i];
        comp[i]=-1;
    }
    
    for(int i=0;i<M;i++) {
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    
    int nc=0;
    for(int i=0;i<N;i++) {
        if(comp[i]==-1) {
            dfs(i,nc);
            nc++;
        }
    }
    
    
    if (nc == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    
    for(int i=0;i<N;i++) {
        comp_to_val[comp[i]].push_back(A[i]);
    }
    
    
    for(int i=0;i<nc;i++)
        sort(comp_to_val[i].begin(),comp_to_val[i].end());
    
    ll ans = 0;
    vector<int> rest;
    for(int i=0;i<nc;i++) {
        ans += comp_to_val[i][0];
        for(int j=1;j<comp_to_val[i].size();j++)
            rest.push_back(comp_to_val[i][j]);
    }
    
    // 2*(nc-1)-nc
    // nc-2
    
    


    if (rest.size() < nc-2) {
        cout << "Impossible" << endl;
        return 0;
    }


    sort(rest.begin(),rest.end());

    
    for(int i=0;i<nc-2;i++)
        ans+=rest[i];
    cout << ans << endl;
    
    
    /*
    
    for(int i=0;i<N;i++) {
        parent[i]=i;
        rankk[i]=0;
        sizes[i]=1;
    }
    
    for(int i=0;i<M;i++) {
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
        edges[y].push_back(x);
        Union(x,y);
    }
    
    
    
    cout << endl;
    for(int i=0;i<N;i++) {
        int id = Find(i);
        values[id].insert({A[i],i});
        printf("%d %d %d\n",i,GetSize(i),numleft();
    }
    */
    
    
    
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 11132