unable to find solution for ZCO contest smart phone question.

#include<stdio.h>
int main()
{
int a[10],i,j,n,temp,sum,count=0;
scanf("\n%d",&n);
for( i=0;i<n;i++)
scanf("\n%d",&a[i]);
for(i=0;i<n-1;i++)
{
for( j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n;i++)
sum=sum+a[i];
sum=(sum/n)+1;
for(i=0;i<n;i++)
{
if(a[i]>=sum)
{
count++;
}
}

printf("\n%d",count*sum);
return 0;
}

here is my code.
it is showing wrong answer.
what is correct one?