#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>


void dfs (int v, const std::vector<std::vector<int>>& g, std::vector<int> *comp, std::vector<bool>* used) {
    (*used)[v] = true;
    comp->push_back(v);
    for (size_t i = 0; i < g[v].size(); ++i) {
        int to = g[v][i];
        if (!(*used)[to]) {
            dfs(to, g, comp, used);
        }
    }
}

std::vector<int> find_comps(const std::vector<std::vector<int>>& g) {
    std::vector<bool> used(g.size());
    used.assign(g.size(), false);

    std::vector<int> comps(g.size());
    int next_comp_id = 0;

    std::vector<int> comp;
    for (int i = 0; i < g.size(); ++i) {
        if (!used[i]) {
            comp.clear();
            dfs(i, g, &comp, &used);

            for (int j : comp) {
                comps[j] = next_comp_id;
            }
            ++next_comp_id;
        }
    }

    return comps;
}

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<long long> ws(n);
    for (int i = 0; i < n; ++i) {
        long long w;
        std::cin >> w;
        ws[i] = w;
    }

    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int l, r;
        std::cin >> l >> r;
        g[l].push_back(r);
        g[r].push_back(l);
    }

    auto comps = find_comps(g);
//    for (int j: comps) {
//        std::cout << j << " ";
//    }
//    std::cout << "\n";

    std::unordered_map<int, std::vector<int>> id_to_comp;
    for (int i = 0; i < n; ++i) {
        int comp_id = comps[i];
        if (id_to_comp.find(comp_id) == id_to_comp.end()) {
            id_to_comp.emplace(comp_id, std::vector<int>());
        }
        id_to_comp[comp_id].push_back(i);
    }

    if (id_to_comp.size() == 1) {
        std::cout << 0;
        return 0;
    }

    std::unordered_map<int, size_t> active_sizes;
    for (const auto& item: id_to_comp) {
        active_sizes[item.first] = item.second.size();
    }

    std::unordered_map<int, std::set<std::pair<int, int>>> comp_id_to_vs;
    for (int i = 0; i < n; ++i) {
        auto w = ws[i];
        auto comp_id = comps[i];
        if (comp_id_to_vs.find(comp_id) == comp_id_to_vs.end()) {
            comp_id_to_vs.emplace(comp_id, std::set<std::pair<int, int>>());
        }
        comp_id_to_vs[comp_id].insert(std::make_pair(w, i));
    }

//    for (const auto& item: comp_id_to_vs) {
//        std::cout << "comp_id: " << item.first << "\n";
//        for (const auto& v: item.second) {
//            std::cout << v.first << " " << v.second << ", ";
//        }
//        std::cout << "\n";
//    }

    std::set<std::pair<int, int>> all_rest_comps;
    std::set<std::pair<int, int>> active_rest_comps;
    for (int comp_id = 1; comp_id < id_to_comp.size(); ++comp_id) {
        auto min_v = comp_id_to_vs[comp_id].begin()->second;
        auto w = ws[min_v];
        all_rest_comps.insert(std::make_pair(w, comp_id));
        bool is_active = active_sizes[comp_id] > 1;
        if (is_active) {
            active_rest_comps.insert(std::make_pair(w, comp_id));
        }
    }

    std::set<std::pair<int, int>> not_used;
    for (int i = 0; i < n; ++i) {
        not_used.insert(std::make_pair(ws[i], i));
    }

    std::unordered_set<int> used;

    long long min_cost = 0;
    for (int i = 0; i < id_to_comp.size() - 1; ++i) {
        auto min_v = comp_id_to_vs[0].begin()->second;
        used.insert(min_v);

        bool is_dying = active_sizes[0] == 1;
//        std::cout << "min_v = " << min_v << " i = " << i << " is_dying = " << is_dying << "\n";
        bool from_all = !is_dying || i == id_to_comp.size() - 2;
        if (!from_all) {
            if (active_rest_comps.empty()) {
                std::cout << "Impossible";
                return 0;
            }

            auto min_w = active_rest_comps.begin()->first;
            auto to_comp_id = active_rest_comps.begin()->second;
            active_rest_comps.erase(active_rest_comps.begin());
            all_rest_comps.erase(std::make_pair(min_w, to_comp_id));

            auto to = comp_id_to_vs[to_comp_id].begin()->second;
//            std::cout << "to_comp_id = " << to_comp_id << " to = " << to << " win_w = " << min_w << "\n";

            min_cost += ws[min_v] + ws[to];
            used.insert(to);

            active_sizes[0] = active_sizes[0] - 1 + active_sizes[to_comp_id] - 1;
            active_sizes.erase(to_comp_id);

            comp_id_to_vs[0].erase(std::make_pair(ws[min_v], min_v));
            for (const auto &item: comp_id_to_vs[to_comp_id]) {
                if (used.find(item.second) == used.end()) {
//                    std::cout << "adding " << item.first << " " << item.second << "\n";
                    comp_id_to_vs[0].insert(std::make_pair(item.first, item.second));
                }
            }
            comp_id_to_vs.erase(to_comp_id);

        } else {
            auto min_w = all_rest_comps.begin()->first;
            auto to_comp_id = all_rest_comps.begin()->second;
            all_rest_comps.erase(all_rest_comps.begin());

            if (active_rest_comps.find(std::make_pair(min_w, to_comp_id)) != active_rest_comps.end()) {
                active_rest_comps.erase(std::make_pair(min_w, to_comp_id));
            }

            auto to = comp_id_to_vs[to_comp_id].begin()->second;

            min_cost += ws[min_v] + ws[to];
            used.insert(to);

            active_sizes[0] = active_sizes[0] - 1 + active_sizes[to_comp_id] - 1;
            active_sizes.erase(to_comp_id);

            comp_id_to_vs[0].erase(std::make_pair(ws[min_v], min_v));
            for (const auto &item: comp_id_to_vs[to_comp_id]) {
                if (used.find(item.second) == used.end()) {
                    comp_id_to_vs[0].insert(std::make_pair(item.first, item.second));
                }
            }
            comp_id_to_vs.erase(to_comp_id);
        }
    }


    std::cout << min_cost;

    return 0;
}

Measured memory_bytes: 39588