#K5486. Maximum Price Change

    ID: 29847 Type: Default 1000ms 256MiB

Maximum Price Change

Maximum Price Change

You are given a sequence of daily prices. Your task is to find the maximum price change over any three consecutive days. The price change for three consecutive days is defined as [ \text{change} = |p_i - p_{i+1}| + |p_{i+1} - p_{i+2}| ] where (p_i, p_{i+1}, p_{i+2}) are the prices on three successive days. For example, if the prices are [5, 3, 8, 10, 7], the maximum price change is 7.

inputFormat

The input is given via standard input (stdin). The first line contains an integer (n) ((n \ge 3)) representing the number of days. The second line contains (n) space-separated integers representing the daily prices.

outputFormat

Output a single integer to standard output (stdout) representing the maximum price change among every three consecutive days.## sample

5
5 3 8 10 7
7