私はプログラムを解決しようとしていますが、例外が何度も発生しています。ここで私を助けてくれるのは私のコードです
import java.util.*;
public class Fashion
{
public static void main(String args[])
{
int sum=0;
Scanner in=new Scanner(System.in);
System.out.println("enter the number of judges");
int x=in.nextInt();
int a[]=new int[x];
if((x<20)&&(x%2==1))
{
System.out.println("score given by judges");
for(int i=0;i<x;i++)
{
a[i]=in.nextInt();
}
}
int mid=(1+x)/2;
for(int k=0;k<mid;k++)
{
if(a[mid+k]==a[mid-k]) //exception here why
{
sum=sum+a[mid+k];
}
}
System.out.println("the number get by the contestant is "+sum);
}
}