import Data.List
main=do
 getLine
 a<-sort.map read.words<$>getLine
 let x=0:0:f 0 0 a
 let y=tail x
 let z=tail y
 print$maximum$zipWith(+)x$zipWith(+)y z
f i c[]=[c]
f i c a@(x:as)
 |i==x=f i(c+1)as
 |otherwise=c:f(i+1)0 a
