VOTERS - SIGSEGV Error

Can anyone tell me why a segmentation fault is occurring?

#include<iostream>
#include<cstdio>
using namespace std;

int main()
{
    long int n1,n2,n3;
    cin >> n1 >> n2 >> n3;
    long int id[100001] = {0};
    long int n;
    for(long int i = 1;i <= n1+n2+n3;i++)
    {
            scanf("%d",&n);
            id[n]++;
    }
    long int ans = 0;
    for(long int i = 0;i < 100001;i++)
            if(id[i] >= 2) ans++;
    cout << ans << endl;
    for(long int i = 0;i < 100001;i++)
            if(id[i] >= 2) cout << i << endl;
    return 0;
}
1 Like

because n1+n2+n3 can be 3*50000

and size of your array is only 100001