Runtime error on Chang and Bitwise OR Problem Code: CHNGOR

my code shows runtimme error! why it is so???(0<n<10ˆ5;t<10)!
though my tc is o(10ˆ6) then why it is so??

#include <stdio.h>

int main(void) {
int t;
scanf("%d",&t);
while(t–){
int n,a[n],ans=0;
scanf("%d",&n);
for(int i=0;i<n;++i) {
scanf("%d",&a[i]);
ans|=a[i];}
printf("%d",ans);
}
return 0;
}

Firstly, please format your code whenever you post in on the forum. Formatted code is much more readable.
Your code shows error because you created an array of size n before you initialised the value of n. In other words, declare a[n] after you have taken the value of n as input.