-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2847.java
More file actions
28 lines (23 loc) · 734 Bytes
/
2847.java
File metadata and controls
28 lines (23 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int score[] = new int[n];
for(int i=0; i<n; i++)
score[i]=Integer.parseInt(br.readLine());
if(n==1){
System.out.println(0);
return;
}
int answer = 0;
for(int i=score.length-1; i>=1; i--){
if(score[i-1]>=score[i]){
answer += score[i-1]-(score[i]-1);
score[i-1]=score[i]-1;
}
}
System.out.println(answer);
}
}