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ớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given an integer array whose length is ~n~. Find the maximum value of ~aj~ – ~ai~ for all 0 ≤ ~i~ ≤ ~j~ < ~n~.
Input
The first line contains an integer ~n~ representing the number of elements in the array (~1~ ≤ ~n~ ≤ ~10^{5}~).
The second line contains ~n~ integers which are elements of the array (|~ai~| ≤ ~2*10{9}~).
Output
An only integer which is the maximum difference.
Sample Input
5
2 4 1 5 3
Sample Output
4
Sample Input
6
10 5 4 3 2 1
Sample Output
0
Bình luận