N = gets.to_i
A = gets.split.map(&:to_i)

first_max = [A.first, A.last].min * 2

first_max.step(0, -2).each do |i|
  result = [i]

  dum = Array.new(N, 0)
  dum[0] = i / 2
  dum[N - 1] = i / 2

  bad = false

  1.upto(N - 1) do |j|
    d = A[j - 1] - dum[j - 1]
    result << d * 2
    dum[j - 1] += d
    dum[j] += d

    if dum[j] > A[j]
      bad = true
      break
    end
  end

  if bad
    next
  end

  if dum.last == A.last
    puts result.join(' ')
    exit
  end
end