n = gets.to_i data = Array.new(n) result = Array.new(n+1) n.times{|i| data[i] = gets.to_i} b = 1 result[0] = data[0]-1 if (data[0]<=0) puts "-1";exit end 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