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.
//package codeforces;

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class D implements Closeable {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    int MOD = 1000 * 1000 * 1000 + 7;

    int sum(int a, int b) {
        a += b;
        return a >= MOD ? a - MOD : a;
    }

    int product(int a, int b) {
        return (int) (1l * a * b % MOD);
    }

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        final int n = nextInt();
        final int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        class Utils {
            int[] a;
            int[] extrema;

            public Utils(int[] a) {
                this.a = a;
                extrema = new int[a.length];
                for(int i = 1; i < a.length - 1; i++) {
                    if(Integer.signum(a[i] - a[i - 1]) * Integer.signum(a[i] - a[i + 1]) > 0) {
                        extrema[i] = i;
                    } else {
                        extrema[i] = extrema[i - 1];
                    }
                }
                extrema[a.length - 1] = extrema[a.length - 2];
            }

            long foo(int i) {
                if(i == 0) {
                    return 0;
                }
                int j = extrema[i];
                if(j == i) {
                    j = extrema[j - 1];
                }
                if(j == 0) {
                    return Math.abs(a[0] - a[i]);
                }
                return Math.max(Math.abs(a[i] - a[j]) + foo(j - 1), Math.abs(a[i] - a[j + 1]) + foo(j));
            }
        }
        class CachedUtils extends Utils {
            long[] cache;
            boolean[] hit;

            public CachedUtils(int[] a) {
                super(a);
                cache = new long[a.length];
                hit = new boolean[a.length];
            }

            @Override
            long foo(int i) {
                if(!hit[i]) {
                    hit[i] = true;
                    cache[i] = super.foo(i);
                }
                return cache[i];
            }
        }

        int i = 0;
        long answer = 0;
        for(int j = 0; j < n - 1; j++) {
            if(a[j + 1] == a[j]) {
                if(j - i + 1 > 1) {
                    int[] b = new int[j - i + 1];
                    System.arraycopy(a, i, b, 0, j - i + 1);
                    answer += new CachedUtils(b).foo(j - i);
                }
                i = j + 1;
            }
        }
        if(n - 1 - i + 1 > 1) {
            int[] b = new int[n - 1 - i + 1];
            System.arraycopy(a, i, b, 0, n - 1 - i + 1);
            answer += new CachedUtils(b).foo(n - 1 - i);
        }
        writer.println(answer);
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        try(D d = new D()) {
            final Thread thread = new Thread(null, new Runnable() {
                @Override
                public void run() {
                    try {
                        d.solve();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }, "ProblemD", 128 << 20);
            thread.start();
            thread.join();
        }
    }

    @Override
    public void close() throws IOException {
        reader.close();
        writer.close();
    }
}