getting a wrong answer for CHEFRP problem although compiled successfully

,

#include<stdio.h>
int main()
{
int i,flag,j,t,pos,min,n,a[1000];
long sum;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d",&n);
flag=0;
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
if(a[j]<2)
{
flag=1;
break;
}
}
if(flag==1)
printf("-1\n");
else
{
min=a[0];
pos=0;
sum=0;
for(j=1;j<n;j++)
{
if(a[j]<min)
{
min=a[j];
pos=j;
}
}
for(j=0;j<n;j++)
{
if(j!=pos)
sum+=a[j];
}
sum+=2;
printf("%d\n",sum);
}
}
return(0);
}

remember you are not allowed to discuss problems while the competition is on…

1 Like

I guess that the admin should block/delete this question since the code for the problem is posted.