Codeforces Round 407 (Div. 1)
A
Functions again
Codeforces
1600
原题
←B →
翻译中…

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function $*f*$, which is defined as follows:

翻译中…

image

翻译中…

In the above formula, $1 ≤ *l* < *r* ≤ *n*$ must hold, where $*n*$ is the size of the Main Uzhlyandian Array $*a*$, and $|*x*|$ means absolute value of $*x*$. But the heroes skipped their math lessons in school, so they asked you for help. Help them calculate the maximum value of $*f*$ among all possible values of $*l*$ and $*r*$ for the given array $*a*$.

翻译中…

Input

翻译中…

The first line contains single integer $*n*$ ($2 ≤ *n* ≤ 10^{5}$) — the size of the array $*a*$.

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ (-$10^{9} ≤ *a*_{*i*} ≤ 10^{9}$) — the array elements.

翻译中…

Output

翻译中…

Print the only integer — the maximum value of $*f*$.

翻译中…

Note

翻译中…

In the first sample case, the optimal value of $*f*$ is reached on intervals $[1, 2]$ and $[2, 5]$.

翻译中…

In the second case maximal value of $*f*$ is reachable only on the whole array.

翻译中…

样例

Input #1
5
1 4 2 3 1
Output #1
3
InputCopy OutputCopy
Input #2
4
1 5 4 7
Output #2
6
InputCopy OutputCopy
题目信息
题号
788A
时间限制
1 s
内存限制
256 MB
标签
动态规划
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。