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.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		if (new File("input.txt").exists())
			in = new BufferedReader(new FileReader("input.txt"));
		else
			in = new BufferedReader(new InputStreamReader(System.in));
		if (new File("output.txt").exists())
			out = new PrintWriter("output.txt");
		else
			out = new PrintWriter(System.out);

		solve();

		in.close();
		out.close();
	}

	final int maxn = 1000 * 1000 + 100;
	final long inf = Long.MAX_VALUE / 3;

	int n;
	int a[] = new int[maxn];

	long d[] = new long[maxn];
	RMQ rmq1;
	RMQ rmq2;

	void solve() throws IOException {
		n = nextInt();
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		rmq1 = new RMQ(n);
		rmq2 = new RMQ(n);

		d[0] = 0;
		rmq1.update(0, a[0]);
		rmq2.update(0, -a[0]);
		for (int j = 1; j < n; j++) {
			d[j] = d[j - 1];
			d[j] = max(d[j], rmq1.getMax(0, j - 1) - a[j]);
			d[j] = max(d[j], rmq2.getMax(0, j - 1) + a[j]);
			rmq1.update(j, d[j - 1] + a[j]);
			rmq2.update(j, d[j - 1] - a[j]);
		}

		long ans = 0;
		long minVal = a[n - 1];
		long maxVal = a[n - 1];
		for (int i = n - 1; i >= 0; i--) {
			minVal = min(minVal, a[i]);
			maxVal = max(maxVal, a[i]);
			ans = max(ans, (i > 0 ? d[i - 1] : 0) + maxVal - minVal);
		}
		
		out.println(ans);

	}

	class RMQ {
		int n;
		long tree[];

		public RMQ(int size) {
			n = 1;
			while (n < size)
				n <<= 1;

			tree = new long[n << 1];
		}

		public void update(int index, long val) {
			update(1, 0, n - 1, index, val);
		}

		private void update(int v, int l, int r, int index, long val) {
			if (l == r) {
				tree[v] = val;
				return;
			}

			int m = (l + r) >> 1;
			if (index <= m)
				update(v * 2, l, m, index, val);
			else
				update(v * 2 + 1, m + 1, r, index, val);
			tree[v] = max(tree[v * 2], tree[v * 2 + 1]);
		}

		public long getMax(int l, int r) {
			return getMax(1, 0, n - 1, l, r);
		}

		private long getMax(int v, int l, int r, int ll, int rr) {
			if (rr < ll)
				return -inf;

			if (l == ll && r == rr)
				return tree[v];

			int m = (l + r) >> 1;
			long maxl = getMax(v * 2, l, m, ll, min(rr, m));
			long maxr = getMax(v * 2 + 1, m + 1, r, max(ll, m + 1), rr);
			return max(maxl, maxr);
		}
	}

	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

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

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

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

	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String str = in.readLine();
			if (str == null)
				return true;
			st = new StringTokenizer(str);
		}
		return false;
	}

}
