// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
void sleep( double sec = 1021 ){
  clock_t s = clock();
  while( clock() - s < CLOCKS_PER_SEC * sec );
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
int p[ N ] , sz[ N ];
int f( int x ){
  return x == p[ x ] ? x : p[ x ] = f( p[ x ] );
}
void uni( int x , int y ){
  x = f( x );
  y = f( y );
  if( x == y ) return;
  p[ x ] = y;
  sz[ y ] += sz[ x ];
}
void build(){

}
int n , m;
LL a[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < n ; i ++ )
    p[ i ] = i , sz[ i ] = 1;
  m = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
  while( m -- ){
    int ai = getint();
    int bi = getint();
    uni( ai , bi );
  }
}
multiset<LL> my;
set< pair<LL,int> > others;
LL ans;
void no(){
  puts( "Impossible" );
  Bye;
}
vector<int> whos[ N ];
multiset<LL> singles;
void solve(){
  int mx = -1;
  for( int i = 0 ; i < n ; i ++ ){
    whos[ f( i ) ].push_back( i );
    if( i != f( i ) ) continue;
    if( mx == -1 or sz[ i ] > sz[ mx ] )
      mx = i;
  }
  for( int i = 0 ; i < n ; i ++ )
    if( f( i ) == mx )
      my.insert( a[ i ] );
    else if( sz[ f( i ) ] == 1 )
      singles.insert( a[ i ] );
    else
      others.insert( { a[ i ] , i } );
  while( not others.empty() ){
    if( my.empty() ) no();
    pair<LL,int> bst = *others.begin();
    others.erase( others.begin() );
    ans += *my.begin();
    ans += bst.first;
    my.erase( my.begin() );
    for( int nxt : whos[ f( bst.second ) ] ){
      if( nxt == bst.second ) continue;
      others.erase( { a[ nxt ] , nxt } );
      my.insert( a[ nxt ] );
    }
  }
  if( my.size() < singles.size() ) no();
  while( singles.size() ){
    ans += *singles.begin();
    singles.erase( singles.begin() );
    ans += *my.begin();
    my.erase( my.begin() );
  }
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 12032