-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIncreasingArray.java
More file actions
42 lines (37 loc) · 852 Bytes
/
IncreasingArray.java
File metadata and controls
42 lines (37 loc) · 852 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
import java.io.*;
/**
*
* Ashish Patel
* e: ashishsushilPatel@gmail.com
* w: https://ashish.me
*
*/
class IncreasingArray {
static PrintWriter pw;
static BufferedReader br;
static StringTokenizer st;
static long nl() {
return Long.parseLong(st.nextToken());
}
static int ni() {
return Integer.parseInt(st.nextToken());
}
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
st = new StringTokenizer(br.readLine());
long t = nl();
st = new StringTokenizer(br.readLine());
long ans = 0;
long max = 0;
for (int i = 0; i < t; ++i) {
long x = nl();
max = Math.max(max, x);
ans += max - x;
}
pw.print(ans);
br.close();
pw.close();
}
}