1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<algorithm>
6 using namespace std;
7 int n;
8 int a[110]={};
9 int f[110][2010]={};
10 int sum[110]={};
11 int sumn=0;
12 int main(){
13 cin>>n;
14 for(int i=1;i<=n;i++){
15 cin>>a[i];
16 sumn+=a[i];
17 sum[i]=sumn;
18 }
19 for(int i=0;i<=sumn;i++){
20 f[0][i]=-1;
21 }
22 f[0][0]=0;
23 for(int i=1;i<=n;i++){
24 for(int j=0;j<=sumn;j++){
25 f[i][j]=f[i-1][j];
26 if(j>=a[i]&&f[i-1][j-a[i]]>-1){
27 f[i][j]=max(f[i][j],f[i-1][j-a[i]]);
28 }
29 if(a[i]>j&&f[i-1][a[i]-j]>-1){
30 f[i][j]=max(f[i][j],f[i-1][a[i]-j]+a[i]-j);
31 }
32 if(j+a[i]<=sumn&&f[i-1][a[i]+j]>-1){
33 f[i][j]=max(f[i][j],f[i-1][a[i]+j]+a[i]);
34 }
35 }
36 }
37 if(f[n][0]>0){
38 cout<<f[n][0]<<endl;
39 }
40 else{
41 cout<<"Impossible"<<endl;
42 }
43 return 0;
44 }