#include #include #include #include #include using namespace std; void pall(stack c, vector w) { int sum = 0; while( !c.empty() ) { sum += w[c.top()]; cout << w[c.top()]<< " "; c.pop(); } cout << endl << "sum=" << sum << endl; } int main() { int N; cin >> N; vector W(N); for(int i = 0 ; i < N; i++ ){ cin >> W[i]; } sort( W.begin(), W.end() ); int half = 0; for( auto x: W ) { half += x; } if( half%2 == 1 ) { cout << "impossible" << endl; return 0; } half = half / 2; stack s; int sum =0; int i = 0; int a = 0; int b = 0; while( 1 ) { if( i >= N ) { if( !s.empty() ) { i = s.top(); s.pop(); sum -= W[i]; i++; } else { cout << "impossible" << endl; return 0; } /* if( i == N-1 ) { // cout << __LINE__ << endl; cout << "impossible" << endl; return 0; } i = s.top(); s.pop(); sum -= W[i]; i++; */ } else if( half == sum + W[i] ) { cout << "possible" << endl; return 0; } else if( half > sum + W[i] ) { sum += W[i]; s.push( i ); i++; } else if( half < sum + W[i] ) { if( s.empty() ) { cout << "impossible" << endl; return 0; } i = s.top(); sum -= W[i]; // assert( sum > 0 ); i++; s.pop(); } else { cout << "arienai" << endl; return 0; } } return 0; }