How can I fix this code?  I can't input a value for n more than 100000 but I have declared it as long long int. 
I tried to solve it but couldn't. Please tell me what is wrong.
#include<stdio.h>
void main() {
    long int n;
    scanf("%ld",&n);
    unsigned long long int a[n];
    unsigned long long int max[n];
    for(unsigned long long int i=0;i<n;i++) {
        scanf("%lld",&a[i]);
    }
    for(unsigned long long int i=0;i<n;i++) {
        unsigned long long int count=0;
        for(unsigned long long int j=0;j<n;j++) {
            if(a[i]==a[j]) {
                count++;
            }
        }
        max[i]=count;
    }
    for(unsigned long long int i=1;i<n;i++) {
        if(max[0]<max[i]) {
            max[0]=max[i];
            a[0]=a[i];
        }
        else if(max[0]==max[i]) {
            if(a[0]>a[i]) {
                a[0]=a[i];
            }
        }
    }
    printf("%lld",a[0]);
}
 
    