In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of consecutive children of a line. A group's sociability is the maximum difference of charisma of two children in the group (in particular, if the group consists of one child, its sociability equals a zero). 

The teacher wants to divide the children into some number of groups in such way that the total sociability of the groups is maximum. Help him find this value.

Input

The first line contains integer n — the number of children in the line (1 ≤ n ≤ 106).

The second line contains n integers ai — the charisma of the i-th child ( - 109 ≤ ai ≤ 109).

Output

Print the maximum possible total sociability of all groups.

Examples

Input

5
1 2 3 1 2


Output

3


Input

3
3 3 3


Output

0

Note

In the first test sample one of the possible variants of an division is following: the first three children form a group with sociability 2, and the two remaining children form a group with sociability 1.

In the second test sample any division leads to the same result, the sociability will be equal to 0 in each group.
#include <bits/stdc++.h>
using namespace std;
long long dp[1000007];
int v[1000007];
int main() {
  int i, j, k, l, m, n;
  long long a, b;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", v + i);
  }
  if (n == 1) {
    cout << 0;
    return 0;
  } else if (n == 2) {
    cout << max(0, abs(v[0] - v[1]));
    return 0;
  }
  int in = 1;
  int dc = 1;
  dp[0] = 0;
  dp[1] = 0;
  int prev;
  for (i = 1; i < n; i++) {
    if (v[i - 1] == v[i]) {
      in = 1;
      dc = 1;
      prev = i - 1;
    } else if (dc && v[i] > v[i - 1]) {
      in = 1;
      dc = 0;
      prev = i - 1;
    } else if (in && v[i] < v[i - 1]) {
      in = 0;
      dc = 1;
      prev = i - 1;
    }
    a = dp[prev + 1] + abs(v[i] - v[prev + 1]);
    b = dp[prev] + abs(v[i] - v[prev]);
    dp[i + 1] = max(a, b);
  }
  cout << dp[n];
  return 0;
}
