Language: C++

#include<cstdio>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,a[100005],prev,next,ans;
int main(void){
	register int i;
	n=read();
	for(i=1;i<=n;++i)
		++a[read()];
	prev=0,next=a[1];
	for(i=0;i<=1e5;prev=a[i],++i,next=a[i+1])
		if(a[i]+prev+next>ans)ans=a[i]+prev+next;
	printf("%d",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         register int i;
      |                      ^
a.cc:20:9: error: reference to 'prev' is ambiguous
   20 |         prev=0,next=a[1];
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:14:17: note:                 'int prev'
   14 | int n,a[100005],prev,next,ans;
      |                 ^~~~
a.cc:20:16: error: reference to 'next' is ambiguous
   20 |         prev=0,next=a[1];
      |                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:22: note:                 'int next'
   14 | int n,a[100005],prev,next,ans;
      |                      ^~~~
a.cc:21:24: error: reference to 'prev' is ambiguous
   21 |         for(i=0;i<=1e5;prev=a[i],++i,next=a[i+1])
      |                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:14:17: note:                 'int prev'
   14 | int n,a[100005],prev,next,ans;
      |                 ^~~~
a.cc:21:38: error: reference to 'next' is ambiguous
   21 |         for(i=0;i<=1e5;prev=a[i],++i,next=a[i+1])
      |                                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:22: note:                 'int next'
   14 | int n,a[100005],prev,next,ans;
      |                      ^~~~
a.cc:22:25: error: reference to 'prev' is ambiguous
   22 |                 if(a[i]+prev+next>ans)ans=a[i]+prev+next;
      |                         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:14:17: note:                 'int prev'
   14 | int n,a[100005],prev,next,ans;
      |                 ^~~~
a.cc:22:30: error: reference to 'next' is ambiguous
   22 |                 if(a[i]+prev+next>ans)ans=a[i]+prev+next;
      |                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:22: note:                 'int next'
   14 | int n,a[100005],prev,next,ans;
      |                      ^~~~
a.cc:22:48: error: reference to 'prev' is ambiguous
   22 |                 if(a[i]+prev+next>ans)ans=a[i]+prev+next;
      |                                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:14:17: note:                 'int prev'
   14 | int n,a[100005],prev,next,ans;
      |                 ^~~~
a.cc:22:53: error: reference to 'next' is ambiguous
   22 |                 if(a[i]+prev+next>ans)ans=a[i]+prev+next;
      |                                                     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:14:22: note:                 'int next'
   14 | int n,a[100005],prev,next,ans;
      |                      ^~~~