http://www.codechef.com/BTCD2012/problems/DOORS

What The Hell is Wrong wd this code …each program i run shows a runtime error
import java.util.;
import java.io.
;
class doors
{
public static void main(String args[])throws IOException
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int a[] = new int [n];
for(int i=0;i<n;i++)
a[i]= (pro(s.nextInt()));
for(int i=0;i<n;i++)
System.out.println(a[i]);
}
public static int pro(int n)throws IOException
{
int a[] = new int[n];
for(int i = 0 ;i<a.length;i++)
a[i] = 0;
for(int i=0;i<a.length;i++)
{ int k=1;
for(int j=i+1;j<=a.length;j= (i+1)*k)
{
if(a[j-1]==0) a[j-1]=1;
else a[j-1]=0;
k++;
}
}
int count = 0;
for(int i = 0;i<a.length;i++)
if(a[i]==1) count++;
return count;
}

}