There is a sequence of non-negative integers of length , the -th element of it is .
A sequence is defined as 'good' if and only if there exists a non negative integer that satisfies the following condition:
for all .
To make this sequence 'good', for each , you can do nothing, or pay coin to replace with any non-negative integer.
The question is, what is the minimum cost to make this sequence 'good'.