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.
import java.io.*;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Math.max;
import static java.lang.Math.min;

import java.util.StringTokenizer;

public class CodeForcesBase {
    static boolean usefile = false;
    static OutputStream outfile;

    static {
        try {
            outfile = new FileOutputStream(new File("output.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    static InputStream inputfile;

    static {
        try {
            inputfile = new FileInputStream(new File("input.txt"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {
        PrintWriter out = usefile ? new PrintWriter(outfile) : new PrintWriter(System.out);
        Scanner sc = usefile ? new Scanner(inputfile) : new Scanner(System.in);
        if (usefile) {
            while (sc.ready()) {
                handle(sc, out);
            }
        } else {
            handle(sc, out);
        }
        out.flush();
        out.close();
    }

    private static void handle(Scanner sc, PrintWriter out) throws IOException {
        // either some dp[j+1]+a[j]-a[i], or some dp[j+1]+a[i]-a[j]
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        long[] dp = new long[n];
        long cmax1 = 0 + a[n - 1];// dp[n] == 0
        long cmax2 = 0 - a[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            dp[i] = max(cmax1 - a[i], max(cmax2 + a[i], dp[i + 1])); // must max i+1 because it could form a group by itself
            cmax1 = max(cmax1, dp[i + 1] + a[i]);
            cmax2 = max(cmax2, dp[i + 1] - a[i]);
        }
        out.println(dp[0]);
    }

    private static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

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

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }


    }
}
