@n = gets.to_i @data = Array.new(@n) @result = Array.new(@n+1) @n.times{|i| @data[i] = gets.to_i} 1.upto(20){|k| def calc(k) b = k return false if b<=0 @result[0] = k @n.times{|i| b = @result[i+1] = (@data[i]-b) if i%2==0 b = @result[i+1] = (b-@data[i]) if i%2==1 if (b<=0 || 10**18