Whats wrong with my solution of KINGSHIP?

I calculated the city with the least population and then multiplied every other cities population and added to the total,why am I still getting a WA

#include<stdio.h>
main()
{
long int t,sum,i,in,l,n;
long int arr[100000];
scanf("%d",&t);
while(t--)
{
    sum=0;
    scanf("%d",&n);
    scanf("%d",&arr[0]);
    l=arr[0];in=0;
    for(i=1;i<n;++i)
    {
       scanf("%d",&arr[i]);
       if(arr[i]<l){l=arr[i];in=i;}

    }
    arr[in]=0;
    for(i=0;i<n;++i)
    {
        sum+=l*arr[i];
    }
    printf("%d\n",sum);


 }
 return 0;
 }

@droftware : You need to use long long to prevent integer overflow .

1 Like