#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <utility>
#include <vector>

#define MAX_N (100000L)
#define MAX_M (MAX_N - 1L)
#define INF (1000000000000000000L)

using namespace std;

void dfs_group(const vector<vector<long>> &adj_lists, long cur,
               vector<long> &gs, long g) {
  gs[cur] = g;
  for (long nxt : adj_lists[cur]) {
    if (gs[nxt] < 0) {
      dfs_group(adj_lists, nxt, gs, g);
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  long N, M, as[MAX_N], xs[MAX_M], ys[MAX_M];
  scanf("%ld %ld", &N, &M);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }
  for (long i = 0; i < M; i++) {
    scanf("%ld %ld", &xs[i], &ys[i]);
  }

  // create graph
  vector<vector<long>> adj_lists(N, vector<long>());
  for (long i = 0; i < M; i++) {
    const long x = xs[i], y = ys[i];
    adj_lists[x].push_back(y);
    adj_lists[y].push_back(x);
  }
  // for (long i = 0; i < N; i++) {
  //   printf("%ld: ", i);
  //   for (long j : adj_lists[i]) {
  //     printf("%ld ", j);
  //   }
  //   printf("\n");
  // }

  // group nodes in each connected component
  long num_g = 0;
  vector<long> gs(N, -1);
  for (long i = 0; i < N; i++) {
    if (gs[i] < 0) {
      dfs_group(adj_lists, i, gs, num_g);
      num_g++;
    }
  }
  // for (long i = 0; i < N; i++) {
  //   printf("i = %ld, gs[i] = %ld\n", i, gs[i]);
  // }

  // create list of minimums in each group
  vector<long> min_as(num_g, INF), min_is(num_g, -1);
  for (long i = 0; i < N; i++) {
    const long a = as[i], g = gs[i];
    if (a < min_as[g]) {
      min_as[g] = a;
      min_is[g] = i;
    }
  }

  // create list of nodes in each excluding the minimum node
  vector<vector<long>> non_min_nodess(num_g, vector<long>());
  for (long i = 0; i < N; i++) {
    const long a = as[i], g = gs[i];
    if (i != min_is[g]) {
      non_min_nodess[g].push_back(i);
    }
  }
  // for (long g = 0; g < num_g; g++) {
  //   printf("g = %ld: ", g);
  //   for (long i : non_min_nodess[g]) {
  //     printf("%ld ", i);
  //   }
  //   printf("\n");
  // }

  // count number of connected components with only 1 node
  long cnt_one_node = 0;
  for (long g = 0; g < num_g; g++) {
    if (non_min_nodess[g].size() == 0) {
      cnt_one_node++;
    }
  }

  // create priority_queues
  priority_queue<long, vector<long>, greater<long>> que_cur;
  priority_queue<pair<long, long>, vector<pair<long, long>>,
                 greater<pair<long, long>>>
      que_other;
  priority_queue<long, vector<long>, greater<long>> que_one;
  // fill queues
  que_cur.push(min_as[0]);
  // printf("add to que_cur: %ld\n", min_as[0]);
  for (long i : non_min_nodess[0]) {
    que_cur.push(as[i]);
    // printf("add to que_cur: %ld\n", as[i]);
  }
  for (long g = 1; g < num_g; g++) {
    if (non_min_nodess[g].size() > 0) {
      que_other.push(make_pair(min_as[g], g));
      // printf("add to que_other: (%ld, %ld)\n", min_as[g], g);
    } else {
      que_one.push(min_as[g]);
    }
  }
  // calculate prim
  long ans = 0;
  while (!que_cur.empty() && !que_other.empty()) {
    const long a_cur = que_cur.top(), a_other = que_other.top().first,
               g_other = que_other.top().second;
    const long cost = a_cur + a_other;
    que_cur.pop();
    que_other.pop();
    // printf("a_cur = %ld, a_other = %ld, g_other = %ld\n", a_cur, a_other,
    //        g_other);
    ans += cost;
    for (long i : non_min_nodess[g_other]) {
      que_cur.push(as[i]);
    }
  }
  while (!que_cur.empty() && !que_one.empty()) {
    const long a_cur = que_cur.top(), a_one = que_one.top();
    que_cur.pop();
    que_one.pop();
    ans += a_cur + a_one;
  }
  if (que_other.empty() && que_one.empty()) {
    printf("%ld\n", ans);
  } else {
    printf("Impossible\n");
  } 

  return 0;
}


Measured memory_bytes: 11764