#include <stdio.h>
#include <vector>

using namespace std;

vector<int> v[20010];
int N, K, M=-1, idx[2];

int main() {
    scanf("%d", &N);

    for(int i=0; i<N; i++) {
        int k;
        scanf("%d", &k);

        for(int i=2; i<=20000; i++) {
            v[i][k%i]++;
            if(M<v[i][k%i]) {
                M=v[i][k%i];
                //idx[0]=i; idx[1]=k%i;
                K=i;
            }
        }
    }

    printf("%d", K);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: