https://www.codechef.com/problems/RRCOPY

https://www.codechef.com/problems/RRCOPY.
please help me solve the time limit exeeceded (tle) issue in my code.I have find the array with distinct elements and then printed the length of the array.
my code is:
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t- -)
{
int n;
scanf("%d",&n);
int a[n];
int i,j,k;
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])
{
for(k=j;k<(n-1);k++)
{
a[k]=a[k+1];
}
n- -;
j- -;
}
}
}
printf("%d\n",n);
}
return 0;
}