P29411 [洛谷] [COCI2010-2011#6] USPON
普及-
题目描述

Problem Background

Tomislav goes mountain climbing.

Problem Description

The mountain trail he walks on can be seen as a sequence of numbers with a length of $n$, where $P_i$ represents the height at position $i$.

A climb is defined as a continuous strictly increasing segment of the trail from a lower to a higher altitude.

To exercise, he wants to walk a segment with the largest possible altitude difference.

The altitude difference of a segment of the trail is defined as the difference between the endpoint and the starting point.

You need to find out the maximum altitude difference he can achieve by walking a segment of the trail.

Input Format

The first line of input contains an integer $n$, representing the length of the trail.

The second line contains $n$ integers $P_i$, representing the height at position $i$.

Output Format

Output a single integer, representing the maximum altitude difference.

If the entire trail does not include any climb, output 0.

Sample Input and Output

Sample Input #1

5
1 2 1 4 6

Sample Output #1

5

Sample Input #2

8
12 20 1 3 4 4 11 1

Sample Output #2

8

Sample Input #3

6
10 8 8 6 4 3

Sample Output #3

0

Notes

Data Size and Constraints

For $100\%$ of the data, it is guaranteed that $1 \le n \le 1000$ and $1 \le P_i \le 1000$.

Translation Note

This problem is translated from COCI2010-2011 CONTEST #6 T2 USPON.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 2 1 4 6
样例输出
5