#P6414. Recover the Original Array

    ID: 19629 Type: Default 1000ms 256MiB

Recover the Original Array

Recover the Original Array

We are given an array \(b\) defined by the formula

\[ b_i = \frac{\sum_{j=1}^{i} a_j}{i} \]

where \(a\) is an unknown array. Your task is to recover the original array \(a\) from the given array \(b\). It can be observed that:

  • \(a_1 = b_1\)
  • For \(i > 1\), \(a_i = i\, b_i - (i-1)\, b_{i-1}\)

Implement the solution so that the code passes all the provided test cases.

inputFormat

The first line contains an integer \(n\), the number of elements in the array \(b\). The second line contains \(n\) space-separated numbers representing the array \(b\).

outputFormat

Output \(n\) space-separated numbers representing the recovered array \(a\). If an element is an integer, output it as an integer.

sample

5
3 3 3 3 3
3 3 3 3 3