gets;p gets.split.map(&:to_i).each_cons(3).count{|a,b,c|a,c=[a,c].sort;b