# 3640. 素数子序列

### include

using namespace std;
typedef long long int ll;
bool isprime(ll x);
int n;
int main()
{
cin>>n;
if(n>3)
{
cout<<”Impossible”<>number;
if(number==0)
cout<<”2”<<endl;
else
{
if(isprime(number))
cout<<number<<endl;
else
cout<<”Impossible”<>number[1]>>number[2];
if(number[1]==0&&number[2]==0)
cout<<”2 3”<<endl;
else if((number[1]==0&&number[2]!=0))
{ if(number[2]==2)
cout<<”3 2”<<endl;
else{
number[1]=2;
if(isprime(number[1])&&isprime(number[2])&&isprime(number[1]+number[2]))
cout<<number[1]<<’ ‘<<number[2]<<endl;
else
cout<<”Impossible”<<endl;}
}
else if((number[2]==0&&number[1]!=0))
{ if(number[1]==2)
cout<<”2 3”<<endl;
else{
number[2]=2;
if(isprime(number[1])&&isprime(number[2])&&isprime(number[1]+number[2]))
cout<<number[1]<<’ ‘<<number[2]<<endl;
else
cout<<”Impossible”<<endl;}
}
else if(number[2]!=0&&number[1]!=0)
{

        if(isprime(number[1])&&isprime(number[2])&&isprime(number[1]+number[2]))
cout<<number[1]<<' '<<number[2]<<endl;
else
cout<<"Impossible"<<endl;
}

}
if(n==3)
{
ll number[4];
for(int i=1; i<4; i++)
{
cin>>number[i];
if(number[i]==0&&i!=3)
number[i]=i+1;
else if(number[i]==0&&i==3)
number[i]=i-1;
}
if(number[1]==2&&number[2]==3&&number[3]==2)
cout<<"2 3 2"<<endl;
else
cout<<"Impossible"<<endl;
}


}

bool isprime(ll x)
{
if(x<=1)return false;
ll spr=(ll)sqrt(1.0*x);
for(ll i=2; i<=spr; i++)
{
if(x%i==0)
return false;
}
return true;
}