Why i am getting runtime(SIG SEGV) error

Question link:https://www.codechef.com/problems/TSORT

MY SOLUTION IS
#include <stdio.h>
int main()
{int i,j,n,a[10],temp;
scanf("%d",&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])
{temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%d\n",a[i]);
}
return 0;
}

Thanks for A2A.

You have created an array of size 10, while in the question, limit is 1000000.

And then you are trying to access the memory locations which are located after the array.

Make the array of size n (which is t in the problem statement) and then sort the array using optimal sorting algorithm.

And please provide well structured code or your submission link, from next time.

This error is because of Array index out of bound.

//