n = gets.to_i
$dams = gets.split.map(&:to_i)

def mountains(start)
  mountains = [start]
  $dams.each do |dam|
    next_mountain = (dam - mountains.last / 2) * 2
    # return true if next_mountain < 0
    mountains << next_mountain
  end
  return false if mountains.first < mountains.last
  return true if mountains.first > mountains.last
  mountains
end

def b_search (min, max)
  mid = (min + max) / 2
  mid += 1 if mid.odd?
  if mid == max
    res = mountains(max)
    if res == true || res == false
      return mountains(min)
    else
      return res
    end
  end
  res = mountains(mid)
  if res == false
    min = mid
  elsif res == true
    max = mid
  else
    return res
  end
  b_search(min, max)
end

res = b_search(0, $dams.first * 2)
res.pop
puts res.join(" ")
