#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
typedef long long INT;
int main(){
    INT N;
    scanf("%lld",&N);
    INT A[100002] = {0};
    INT max=0;
    for(INT i=0;i<N;i++){
        INT a;
        scanf("%lld",&a);
        max=MAX(max,a);
        if (a>0) A[a-1]++;
        A[a]++;
        A[a+1]++;
    }
    INT result = 0;
    for(INT i=0;i<=max;i++){
        result = MAX(result,A[i]);
    }
    printf("%lld", result);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_720/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_720/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [5 x i8] c"%lld\00", align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
  %N = alloca i64, align 8
  %A = alloca [100002 x i64], align 16
  %a = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %N) #5
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
  call void @llvm.lifetime.start.p0(i64 800016, ptr nonnull %A) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800016) %A, i8 0, i64 800016, i1 false)
  %0 = load i64, ptr %N, align 8, !tbaa !5
  %cmp34 = icmp sgt i64 %0, 0
  br i1 %cmp34, label %for.body, label %for.body13.preheader

for.cond10.preheader.loopexit:                    ; preds = %if.end
  %1 = add nuw i64 %cond, 1
  br label %for.body13.preheader

for.body13.preheader:                             ; preds = %entry, %for.cond10.preheader.loopexit
  %max.0.lcssa = phi i64 [ 1, %entry ], [ %1, %for.cond10.preheader.loopexit ]
  %min.iters.check = icmp ult i64 %max.0.lcssa, 4
  br i1 %min.iters.check, label %for.body13.preheader43, label %vector.ph

vector.ph:                                        ; preds = %for.body13.preheader
  %n.vec = and i64 %max.0.lcssa, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %4, %vector.body ]
  %vec.phi41 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %5, %vector.body ]
  %2 = getelementptr inbounds [100002 x i64], ptr %A, i64 0, i64 %index
  %wide.load = load <2 x i64>, ptr %2, align 16, !tbaa !5
  %3 = getelementptr inbounds i64, ptr %2, i64 2
  %wide.load42 = load <2 x i64>, ptr %3, align 16, !tbaa !5
  %4 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %vec.phi, <2 x i64> %wide.load)
  %5 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %vec.phi41, <2 x i64> %wide.load42)
  %index.next = add nuw i64 %index, 4
  %6 = icmp eq i64 %index.next, %n.vec
  br i1 %6, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %4, <2 x i64> %5)
  %7 = call i64 @llvm.vector.reduce.smax.v2i64(<2 x i64> %rdx.minmax)
  %cmp.n = icmp eq i64 %max.0.lcssa, %n.vec
  br i1 %cmp.n, label %for.cond.cleanup12, label %for.body13.preheader43

for.body13.preheader43:                           ; preds = %for.body13.preheader, %middle.block
  %i9.039.ph = phi i64 [ 0, %for.body13.preheader ], [ %n.vec, %middle.block ]
  %result.038.ph = phi i64 [ 0, %for.body13.preheader ], [ %7, %middle.block ]
  br label %for.body13

for.body:                                         ; preds = %entry, %if.end
  %i.036 = phi i64 [ %inc8, %if.end ], [ 0, %entry ]
  %max.035 = phi i64 [ %cond, %if.end ], [ 0, %entry ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %a) #5
  %call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %a)
  %8 = load i64, ptr %a, align 8
  %cond = call i64 @llvm.smax.i64(i64 %max.035, i64 %8)
  %cmp3 = icmp sgt i64 %8, 0
  br i1 %cmp3, label %if.then, label %if.end

if.then:                                          ; preds = %for.body
  %sub = add nsw i64 %8, -1
  %arrayidx = getelementptr inbounds [100002 x i64], ptr %A, i64 0, i64 %sub
  %9 = load i64, ptr %arrayidx, align 8, !tbaa !5
  %inc = add nsw i64 %9, 1
  store i64 %inc, ptr %arrayidx, align 8, !tbaa !5
  br label %if.end

if.end:                                           ; preds = %if.then, %for.body
  %arrayidx4 = getelementptr inbounds [100002 x i64], ptr %A, i64 0, i64 %8
  %10 = load <2 x i64>, ptr %arrayidx4, align 8, !tbaa !5
  %11 = add nsw <2 x i64> %10, <i64 1, i64 1>
  store <2 x i64> %11, ptr %arrayidx4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %a) #5
  %inc8 = add nuw nsw i64 %i.036, 1
  %12 = load i64, ptr %N, align 8, !tbaa !5
  %cmp = icmp slt i64 %inc8, %12
  br i1 %cmp, label %for.body, label %for.cond10.preheader.loopexit

for.cond.cleanup12:                               ; preds = %for.body13, %middle.block
  %result.0..lcssa = phi i64 [ %7, %middle.block ], [ %result.0., %for.body13 ]
  %call24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i64 noundef %result.0..lcssa)
  call void @llvm.lifetime.end.p0(i64 800016, ptr nonnull %A) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %N) #5
  ret i32 0

for.body13:                                       ; preds = %for.body13.preheader43, %for.body13
  %i9.039 = phi i64 [ %inc22, %for.body13 ], [ %i9.039.ph, %for.body13.preheader43 ]
  %result.038 = phi i64 [ %result.0., %for.body13 ], [ %result.038.ph, %for.body13.preheader43 ]
  %arrayidx14 = getelementptr inbounds [100002 x i64], ptr %A, i64 0, i64 %i9.039
  %13 = load i64, ptr %arrayidx14, align 8, !tbaa !5
  %result.0. = call i64 @llvm.smax.i64(i64 %result.038, i64 %13)
  %inc22 = add nuw i64 %i9.039, 1
  %exitcond.not = icmp eq i64 %inc22, %max.0.lcssa
  br i1 %exitcond.not, label %for.cond.cleanup12, label %for.body13, !llvm.loop !12
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i64> @llvm.smax.v2i64(<2 x i64>, <2 x i64>) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.smax.v2i64(<2 x i64>) #4

attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
