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

typedef long long ll;

const int N = 1e5 + 10;
int a[N], mark[N];
vector<int> adj[N], v[N];

void dfs(int root, int col) {
    mark[root] = col;
    for (int i = 0; i < adj[root].size(); i++) {
        int u = adj[root][i];
        if (!mark[u])
            dfs(u, col);
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, x, y;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if (!mark[i]) {
            cnt++;
            dfs(i, cnt);
        }
    if (n < 2 * cnt - 2) {
        cout << "Impossible\n";
        return 0;
    }
    for (int i = 0; i < n; i++) {
        v[mark[i]].push_back(a[i]);
    }
    for (int i = 1; i <= cnt; i++)
        sort(v[i].begin(), v[i].end());
    ll ans = 0;
    if (cnt > 1) {
        vector<int> u;
        for (int i = 1; i <= cnt; i++) {
            ans += v[i][0];
            for (int j = 1; j < v[i].size(); j++)
                u.push_back(v[i][j]);
        }
        sort(u.begin(), u.end());
        for (int i = 0; i < cnt - 2; i++)
            ans += u[i];
    }
    cout << ans << "\n";
    return 0;
}
