#!/bin/ruby n = gets.strip.to_i a = gets.strip a = a.split(' ').map(&:to_i) result = 0 flag = 1 a.each_with_index do |x, i| a.drop(flag).each_with_index do |y, c| if (x - y).abs <= 1 result += 1 break end end flag += 1 end print result