RRSTONE ERROR EVEN THOUGH THE CODE IS CORRECT!

SEE my code for RRSTONE,Its working very well but why codechef is showing wrong result!!!

#include<stdio.h>
#include<stdlib.h>
int main()
{
long int n,k;
long int max=0,i=0,j=0;
scanf("%ld%ld",&n,&k);
long int *A=(long int *)calloc(n,sizeof(int));
while(i<n)
{
scanf("%ld",&A[i]);
i++;
}
x:
i=0;
max=A[i];
while(i<n)
{

if(max<A[i])
{
	max=A[i];
	i++;		
}else {
max=max;
i++;
}
}		
i=0;

if(k!=0)
{j=0;
while(j<n)
{
A[j]=max-A[j];
j++;
}if(k%2==0)
	{
	k++;
	goto x;
	}
} else{ goto r;
}

r:
j=0;
while(j<n)
{
printf("%ld ",A[j]);
j++;
}return(0);
}
//