Explain the following code..especially the loop part #1 & #2 of below code:-
[Code is printing the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is <=1].
int main() {
int n,k,max = 0;
cin>>n;
int a[100]={0};
for(int i = 0;i<n;i++){ //#1
cin>>k;
a[k]++;
}
for(int i = 0;i<n-1;i++){ //#2
if(a[i]+a[i+1]> max) max = a[i]+a[i+1];
}
cout<<max;
return 0;
}