#K57332. Maximum Adjacent Height Difference

    ID: 30397 Type: Default 1000ms 256MiB

Maximum Adjacent Height Difference

Maximum Adjacent Height Difference

You are given the heights of n students standing in a line. Your task is to compute the maximum absolute difference between the heights of any two adjacent students.

Formally, given a sequence of heights \(h_1, h_2, \dots, h_n\), you need to calculate: $$\max_{2 \leq i \leq n} \left|h_i - h_{i-1}\right|.$$ If there is only one student, the answer is 0.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains an integer n representing the number of students.
  • The second line contains n space-separated integers, where each integer represents the height of a student.

outputFormat

Output a single integer which is the maximum absolute difference between any two adjacent heights. If n is 1, output 0.

## sample
5
1 5 9 3 7
6