#include <stdio.h>
int main()
{
int N, M = 2;
int a[N];
for(int i=0;i<N;i++) {
if(a[i]>M) M = a[i];
}
int primeNum[1000],i,j,len=0;
for(i=2;i<M;i++)
{
for(int j=0;j<len;j++)
{
if(i%primeNum[j]==0) break;
}
if(j==len) a[len++] = i;
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N-i-1;j++)
{
int FirstIsPrime = 0;
int SecondIsPrime = 0;
for(int k=0;k<len;k++)
{
if(a[j]==primeNum[k]) FirstIsPrime = 1;
}
for(int k=0;k<len;k++)
{
if(a[j+1]==primeNum[k]) SecondIsPrime = 1;
}
if(FirstIsPrime==0 && SecondIsPrime==1)
{
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
else if(FirstIsPrime==1 && SecondIsPrime==1 && a[j]<a[j+1])
{
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
else if(FirstIsPrime==0 && SecondIsPrime==0 && a[j]>a[j+1])
{
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpCnsKCWludCBOLCBNID0gMjsKCXNjYW5mKCIlZCIsICZOKTsKCWludCBhW05dOwoJZm9yKGludCBpPTA7aTxOO2krKykgewoJCXNjYW5mKCIlZCIsICZhW2ldKTsKCQlpZihhW2ldPk0pIE0gPSBhW2ldOwoJfQoJCglpbnQgcHJpbWVOdW1bMTAwMF0saSxqLGxlbj0wOwoJZm9yKGk9MjtpPE07aSsrKQoJewoJCWZvcihpbnQgaj0wO2o8bGVuO2orKykKCQl7CgkJCWlmKGklcHJpbWVOdW1bal09PTApIGJyZWFrOwoJCX0KCQlpZihqPT1sZW4pIGFbbGVuKytdID0gaTsKCX0KCQoJZm9yKGludCBpPTA7aTxOO2krKykKCXsKCQlmb3IoaW50IGo9MDtqPE4taS0xO2orKykKCQl7CgkJCWludCBGaXJzdElzUHJpbWUgPSAwOwoJCQlpbnQgU2Vjb25kSXNQcmltZ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