prob: https://codeforces.com/contest/1486/problem/A
editorial:
Let’s consider the smallest amount of blocks we need to make the first i heights ascending. As heights are non-negative and ascending the heights should look like 0,1,2,3,…,i−1, so the minimum sum is (i−1)⋅i/2. It turns out that this is the only requirement. If it’s not the case for every prefix the answer is NO because we can’t make some prefix ascending. Otherwise the answer is YES because you can move the blocks right till there is at least i blocks in the i-th stack and this would make the heights ascending.