Submit solution
Points:
50.00
Time limit:
1.0s
Memory limit:
256M
Input:
stdin
Output:
stdout
Author:
Suggester:
Problem type
Given an integer sequence of n elements ~a_1, a_2, …, a_n~. Find two indices i, j such that i < j and the difference ~a_j - a_i~ is the largest.
Input: from the standard device has the following format:
- The first line contains a positive integer n (2 ≤ n ≤ ~10^5~);
- The second line contains n positive integers ~a1, a2, …, an~ ~(0 ≤ a_i ≤ 10^9)~.
Output: Output to the standard device a single integer which is the largest value of the difference ~a_j - a_i~.
Exam:
Input 1
3 1 2 3
Output 1
2
Input 2
4
2 5 1 3
Output 2
3
Comments