This page is still under construction.

Parts of this page are still being built. What you see may change.

Subin and the Sequence

Interview

Time limit1sMemory limit32 MB

Summary
Given the prefix averages of a sequence, recover the original sequence term by term.
Level

Easy1 of 10

Topics
Prefix sum, Math
Solved
No attempts yet

Problem

수빈이는 심심해서 수열을 가지고 놀고 있다. 먼저, 정수 수열 A를 쓴다. 그리고 그 아래에 정수 수열 A의 해당 항까지의 평균값을 그 항으로 하는 정수 수열 B를 쓴다. 

예를 들어, 수열 A가 1, 3, 2, 6, 8이라면, 수열 B는 1/1, (1+3)/2, (1+3+2)/3, (1+3+2+6)/4, (1+3+2+6+8)/5, 즉, 1, 2, 2, 3, 4가 된다. 

수열 B가 주어질 때, 수빈이의 규칙에 따른 수열 A는 뭘까?

Input

첫째 줄에는 수열 B의 길이만큼 정수 N(1 ≤ N ≤ 100)이 주어지고, 둘째 줄에는 수열 Bi를 이루는 N개의 정수가 주어진다. (1 ≤ Bi ≤ 109)

Output

첫째 줄에는 수열 A를 이루는 N개의 정수를 출력한다. (1 ≤ Ai ≤ 109)

Examples4

  1. Example 1

    Input
    1
    2
    
    Expected output
    2
    
  2. Example 2

    Input
    4
    3 2 3 5
    
    Expected output
    3 1 5 11
    
  3. Example 3

    Input
    5
    1 2 2 3 4
    
    Expected output
    1 3 2 6 8
    
  4. Example 4

    Input
    3
    1 2 3
    
    Expected output
    1 3 5