Help me in solving LARGESECOND problem

My issue

anyone have a solution which doesn’t exceed timelimit for test case #3

My code

#include <stdio.h>
int solve()
{
    int n, i, j, sum=0, max=0;
    scanf("%d", &n);
    int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(a[i]==a[j])
            {
                a[j]=0;
            }
            sum=a[i]+a[j];
            if(sum>max)
            {
                max=sum;
            }
        }
    }
    printf("%d\n", max);
}
int main() {
int t;
scanf("%d", &t);
while(t--)
{
    solve();
}
	return 0;
}


Learning course: Arrays using C
Problem Link: CodeChef: Practical coding for everyone

this is my code !
include <stdio.h>
include <limits.h>
int main(void) {
int t;
scanf(“%d”,&t);
int i=0;
while(i<t){
int n;
scanf(“%d”,&n);
int arr[n];
for(int j=0;j<n;j++)
scanf(“%d”,&arr[j]);
int max=INT_MIN;
int smax=INT_MIN;
for(int j=0;j<n;j++){
if(arr[j]>max)
max=arr[j];
}
for(int j=0;j<n;j++){
if(arr[j]>smax && arr[j]!=max)
smax=arr[j];
}
printf(“%d\n”,max+smax);
i++;
}
return 0;
}