Why is my code not accepted by codechef ?It is giving a NZEC error everytime I try submitting it.

import java.util.;
import java.lang.
;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
if(t>10||t<1)System.exit(0);
long p=1,j,n,k,min=0,suml=0,sumr=0;
int i;
long a[];
long ret[]=new long[t];
for(i=0;i<t;i++)
{
n=sc.nextLong();
if(n<2||n>(long)Math.pow(10,5))System.exit(0);
k=sc.nextLong();
if(k<2||k>(long)Math.pow(10,9))System.exit(0);
a=new long[(int)n];
for(j=0;j<n;j++)
{
a[(int)j]=sc.nextLong();
a[(int)j]=(long)Math.pow(a[(int)j],k);
}
min=(long)Math.abs(sum(a,1,n)-a[0]);
for(j=2;j<n;j++)
{
suml=sum(a,0,j);
sumr=sum(a,j,n);
if(min==0)break;
if((long)Math.abs(sumr-suml)<min)
{
p=j;
min=(long)Math.abs(sumr-suml);
}
}
ret[i]=p;
p=1;
}
for(i=0;i<t;i++)
System.out.println(ret[i]);
}
static long sum(long a[],long p,long q)
{
long sum=0;
for(long i=p;i<q;i++)sum+=a[(int)i];
return sum;
}
}