def ascan; gets.split.map(&:to_i); end gets aa = ascan.sort lis = [1] aa.each_cons(2) do |a,b| if (b-a).abs <= 1 lis[-1] += 1 else lis << 1 end end hoge = lis.map{|e| e%4}.reduce(:^) # p lis.map{|e| e%4} puts hoge == 0 ? :Second : :First #true => first def guchoku(set, turn = true) return !turn if set.empty? set.each do |e| new_set = set.select{|x| (x-e).abs > 1} return turn if guchoku(new_set, !turn) == turn end return !turn end #p guchoku(aa) # 1 2 3 4 5 6 7 8 9 # t t t f t t t f t