// yuki 929 よくあるボールを移動するやつ // 2019.12.4 bal4u #include #if 1 int getchar_unlocked(void); #define gc() getchar_unlocked() #else #define gc() getchar() #endif #define ABS(x) ((x)>=0? (x): -(x)) int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int main() { int s, N; unsigned ans; N = in(); ans = 0, s = 0; while (N--) s -= in()-1, ans += ABS(s); printf("%u\n", ans); return 0; }