n=gets.to_i a=gets.split(" ").map{|e| e.to_i}.sort ans=a[0] a.each_cons(2){|e1,e2| ans+=(e2-e1>1)?e2:0} puts ans