Whats wrong with my code for http://www.codechef.com/problems/MAXCOUNT

#include

using namespace std;
 
void InsertionSort(long *arr,long n)
{
 
    long i,key;
   
 
    for(long j=1;j<n;j++)
    {
        i=j-1;
        key=arr[j];
 
        while(i>=0&&arr[i]>key)
        {
           arr[i+1]=arr[i];
           i--;
        }
        arr[i+1]=key;
    }
 
    
}
 
 
 
void PrlongMaxRepeated(long *arr,long n)
{
long currentValue = arr[0];
long currentCount = 1;
long maxValue = arr[0];
long maxCount = 1;
 
for(long i=1;i<n;i++)
{
  if(arr[i] == currentValue) 
  {
    currentCount++;
  }
  else 
  {
    // is this greater than max count
    if(currentCount > maxCount) 
    {
      maxCount = currentCount;
      maxValue = currentValue;
    }
 
    // reset values
    currentValue = arr[i];
    currentCount = 1;
  }
}
 
cout<<maxValue<<"  "<<maxCount<<endl;
 
}
 
 
 
 
int main()
{
 
long TestCases;
cin>>TestCases;
 
long **A = new long*[TestCases];;
long *size = new long[TestCases];
 
long j=0;
 
while(true)
{
	long n;
	cin>>n;
	size[j]=n;
	A[j]= new long[n];
 
	for(long i=0;i<n;i++)
	{
		cin>>A[j][i];
	}
	
	j++;
	
	if(j==TestCases)
		break;
 
}

for(long i=0;i<TestCases;i++)
{	
	InsertionSort(A[i],size[i]);
}
 
for(long i=0;i<TestCases;i++)
{	
	PrlongMaxRepeated(A[i],size[i]);
}
 
 
/*for(long i=0;i<TestCases;i++)
{
	
	
	for(long j=0;j<size[i];j++)
	{
		cout<<A[i][j];
	}
	cout<<endl;
}*/

return 0;
 
       
}

I hope some one can answer the question.