n = int(input()) b = [] f = 0 a_01 = [] a_23 = [1] m_01 = 1 m_23 = 1 for i in range(n): b.append(int(input())) if f <= 1: if f == 0: if b[i] == 1: print(-1) exit() ai = b[i] - a_23[-1] else: ai = a_01[-1] - b[i] a_01.append(ai) m_01 = min(m_01, ai) else: if f == 2: ai = b[i] - a_01[-1] if b[i] == 1: print(-1) exit() else: ai = a_23[-1] - b[i] a_23.append(ai) m_23 = min(m_23, ai) f = (f + 1) % 4 #print(a_01) #print(a_23) if m_23 + m_01 <= 0: print(-1) else: f = 3 a_01.reverse() a_23.reverse() print(n+1) if m_01 > 0 and m_23 > 0: m = 0 elif m_01 < m_23: m = -m_01 + 1 else: m = m_23 - 1 for i in range(n + 1): if f <= 1: a = a_01.pop() + m else: a = a_23.pop() - m f = (f + 1) % 4 print(a)