atcoder#ARC136C. [ARC136C] Circular Addition
[ARC136C] Circular Addition
Score : points
Problem Statement
We have an integer sequence of length : (note that its index is -based). Initially, all elements of are .
You can repeat the following operation any number of times.
- Choose integers (, ). Then, for every such that , increase the value of by .
You are given an integer sequence of length : . Find the minimum number of operations needed to make equal .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
1 2 1 2
2
We should do the following.
- Initially, we have .
- Do the operation with , making .
- Do the operation with , making .
5
3 1 4 1 5
7
1
1000000000
1000000000