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

using ll = long long;

const int N = 100005;

int n, m, c, a[N], v[N];
vector<int> e[N];
priority_queue<int, vector<int>, greater<int>> p, q;
ll r;

void f(int x, int y){
    v[x] = 1;
    p.push(a[x]);
    for(int i : e[x]) if(i != y) f(i, x);
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    for(int x, y; m--; ){
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i = 0; i < n; i++){
        if(v[i]) continue;
        c++;
        f(i, 0);
        r += p.top();
        p.pop();
        while(!p.empty()){ q.push(p.top()); p.pop(); }
    }
    for(int i = 0; i < c - 2; i++){
        if(q.empty()){ puts("Impossible"); return 0; }
        r += q.top();
        q.pop();
    }
    printf("%lld\n", (c > 1) * r);
}