Run time error [problem code- SIDPRIME]

#include <stdio.h>
#include<math.h>

int main(void) {

// your code goes here
int i,j,k,a[1000],n,q,l,r,c=0,ans=0;
scanf("%d",&n);
for(i=0;i<n;i++)
    scanf("%d",&a[i]);
scanf("%d",&q);
for(i=0;i<q;i++){
     scanf("%d%d",&l,&r);
     for(j=0;j<n;j++){
       if(a[j]>=l && a[j]<=r){
          for(k=1;k<=a[j];k++){
            if(a[j]%k==0)
             c++;
         }
     }
     if(c==2)
      ans++;
     c=0;
    }
   printf("%d\n",ans);
   ans=0;
  }
return 0;

}

Here are constraints to the problem. Watch them carefully…
Constraints
1 ≤ N ≤ 10^6.

1 ≤ Ai ≤ 10^6.

1 ≤ Q ≤ 10.

1 ≤ L ≤ R ≤ 10^6.

You have taken int a[1000].

Is 1000=10^6.

How can you go array out of index.
That’s why it is giving Run Time error.

Take a look at this discussion, [Beginners arrays][1]

Hope this helps!!
[1]: https://discuss.codechef.com/questions/108911/just-a-little-help-to-beginners-about-initializing-arrays-run-time-error

//