CSES - Increasing Array

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
CSES
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

On each move, you may increase the value of any element by one. What is the minimum number of moves required?

Input

  • The first input line contains an integer ~n~: the size of the array.

  • Then, the second line contains ~n~ integers ~x_1,x_2,\ldots,x_n~: the contents of the array.

Output

  • Print the minimum number of moves.

Constraints

  • ~1 \le n \le 2 \cdot 10^5~
  • ~1 \le x_i \le 10^9~

Example Input

5
3 2 5 1 7

Example Output

5

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.