def lscan; gets.split.map(&:to_i); end gets p ([-2]+lscan).sort.each_cons(2).filter{|a,b| b-a > 1}.map{|a,b| b}.reduce(:+)