Help me in solving ELECTN problem

My issue

class Codechef
{
public static void main (String args) throws java.lang.Exception
{
// your code goes here
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while(t–>0){
int n=in.nextInt();
int x= in.nextInt();
int a=new int[n];
int count=0;
for(int j=0;j<n;j++){
a[n]=in.nextInt();
if(a[j]>=x){
count++;
}
}System.out.println(count);
}
}
}
please find the error and how to solve it

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner in=new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0){
		    int n=in.nextInt();
		    int x= in.nextInt();
		    int a[]=new int[n];
		    int count=0;
		    for(int j=0;j<n;j++){
		        a[n]=in.nextInt();
		        if(a[j]>=x){
		            count++;
		        } 
		}System.out.println(count);
	}
}
}

Problem Link: ELECTN Problem - CodeChef

@usha23
plzz refer the following solution

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while (T-->0) {
		    int len = sc.nextInt();
		    int min = sc.nextInt();
		    int count =0;
		    for (int i=0;i<len;i++) {
		        if (sc.nextInt()>=min) {
		            count++;
		        }
		    }
		    System.out.println(count);
		}
	}
}