Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as follows:$f(l, r) = \sum_{i = l}^{r - 1}|a [ i ] - a [ i + 1 ]|\cdot(- 1)^{i - l}$

In the above formula, 1 ≤ l < r ≤ n must hold, where n is the size of the Main Uzhlyandian Array a, and |x| means absolute value of x. But the heroes skipped their math lessons in school, so they asked you for help. Help them calculate the maximum value of f among all possible values of l and r for the given array a.


-----Input-----

The first line contains single integer n (2 ≤ n ≤ 10^5) — the size of the array a.

The second line contains n integers a_1, a_2, ..., a_{n} (-10^9 ≤ a_{i} ≤ 10^9) — the array elements.


-----Output-----

Print the only integer — the maximum value of f.


-----Examples-----
Input
5
1 4 2 3 1

Output
3
Input
4
1 5 4 7

Output
6


-----Note-----

In the first sample case, the optimal value of f is reached on intervals [1, 2] and [2, 5].

In the second case maximal value of f is reachable only on the whole array.

Difficulty: MEDIUM_HARD

Solutions:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = [0] * n
for i in range(n - 1):
	x = abs(a[i] - a[i + 1])
	if i % 2 == 0:
		b[i] = x
		c[i] = -x
	else:
		b[i] = -x
		c[i] = x

def maxSubArray(arr):
	best = 0
	current = 0
	for x in arr:
		current = max(0, current + x)
		best = max(best, current)
	return best
print(max(maxSubArray(c), maxSubArray(b)))


n = int(input())
a = list(map(int, input().split()))
(da, p) = ([], 1)
for i in range(n - 1):
	da.append(p * abs(a[i] - a[i + 1]))
	p *= -1
(m1, m2, s1, s2) = (0, 0, 0, 0)
for x in da:
	s1 += x
	if s1 < 0:
		s1 = 0
	s2 -= x
	if s2 < 0:
		s2 = 0
	m1 = max(m1, s1)
	m2 = max(m2, s2)
print(max(m1, m2))


import sys
from io import BytesIO, IOBase
import os
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
if n == 2:
	print(abs(a[0] - a[1]))
	exit()
(mx_cur1, mx_glob1) = (abs(a[0] - a[1]), abs(a[0] - a[1]))
for i in range(1, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** i
	mx_cur1 = max(mx_cur1 + tmp, tmp)
	mx_glob1 = max(mx_cur1, mx_glob1)
(mx_cur2, mx_glob2) = (abs(a[1] - a[2]), abs(a[1] - a[2]))
for i in range(2, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** (i - 1)
	mx_cur2 = max(mx_cur2 + tmp, tmp)
	mx_glob2 = max(mx_glob2, mx_cur2)
print(max(mx_glob1, mx_glob2))


def main():
	input()
	aa = list(map(int, input().split()))
	(a, s) = (aa[0], 1)
	u = c = mi = ma = 0
	for b in aa:
		c += abs(a - b) * s
		a = b
		s *= -1
		if ma < c:
			ma = c
			u = ma - mi
		elif mi > c:
			mi = c
	(a, s) = (aa[0], -1)
	v = c = mi = ma = 0
	for b in aa:
		c += abs(a - b) * s
		a = b
		s *= -1
		if ma < c:
			ma = c
			v = ma - mi
		elif mi > c:
			mi = c
	print(max(u, v))

def __starting_point():
	main()
__starting_point()


n = int(input())
a = list(map(int, input().split()))
aux = 0
minaux = 0
maxim = 0
results = []
for i in range(1, n):
	results.append(abs(a[i - 1] - a[i]))
for i in range(0, n - 1):
	if i % 2 == 1:
		condition = -results[i]
	else:
		condition = results[i]
	aux += condition
	minaux -= condition
	if aux > maxim:
		maxim = aux
	if condition > maxim:
		maxim = condition
	if minaux > maxim:
		maxim = minaux
	if minaux < 0:
		minaux = 0
	if aux < 0:
		aux = 0
print(maxim)


import sys

def read_ints():
	return [int(x) for x in sys.stdin.readline().strip().split()]

def main():
	N = read_ints()[0]
	a = read_ints()
	nums = [abs(a[i] - a[i + 1]) for i in range(N - 1)]
	N -= 1
	odd = [0] * N
	even = [0] * N
	odd[0] = nums[0]
	for ix in range(1, N):
		odd[ix] = max(nums[ix], even[ix - 1] + nums[ix])
		even[ix] = odd[ix - 1] - nums[ix]
	print(max(max(odd), max(even)))
main()


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far

def solve():
	n = int(input())
	temp = list_input()
	arr1 = []
	arr2 = []
	c = 0
	for i in range(n - 1):
		var = abs(temp[i] - temp[i + 1])
		if c % 2 == 0:
			arr1.append(var)
			arr2.append(-var)
		else:
			arr1.append(-var)
			arr2.append(var)
		c += 1
	print(max(maxSubArraySum(arr1, n - 1), maxSubArraySum(arr2, n - 1)))
t = 1
for _ in range(t):
	solve()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999
alphabets = 'abcdefghijklmnopqrstuvwxyz'

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class SegTree:

	def __init__(self, n):
		self.N = 1 << n.bit_length()
		self.tree = [0] * (self.N << 1)

	def update(self, i, j, v):
		i += self.N
		j += self.N
		while i <= j:
			if i % 2 == 1:
				self.tree[i] += v
			if j % 2 == 0:
				self.tree[j] += v
			(i, j) = (i + 1 >> 1, j - 1 >> 1)

	def query(self, i):
		v = 0
		i += self.N
		while i > 0:
			v += self.tree[i]
			i >>= 1
		return v

def SieveOfEratosthenes(limit):
	isPrime = [True] * (limit + 1)
	isPrime[0] = isPrime[1] = False
	primes = []
	for i in range(2, limit + 1):
		if not isPrime[i]:
			continue
		primes += [i]
		for j in range(i * i, limit + 1, i):
			isPrime[j] = False
	return primes

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		n = ri()
		a = ria()
		pa = []
		na = []
		f = 0
		for i in range(n - 1):
			val = abs(a[i] - a[i + 1])
			if f:
				val = -val
			pa.append(val)
			na.append(-val)
			f = 1 - f
		maxint = INF

		def maxSubArraySum(a, size):
			max_so_far = -maxint - 1
			max_ending_here = 0
			for i in range(size):
				max_ending_here = max_ending_here + a[i]
				max_so_far = max(max_so_far, max_ending_here)
				max_ending_here = max(0, max_ending_here)
			return max_so_far
		wi(max(maxSubArraySum(pa, n - 1), maxSubArraySum(na, n - 1)))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
a = list(map(int, input().split()))
dp = [[0, 0] for i in range(n)]
dp[0][1] = abs(a[1] - a[0])
maxi = abs(a[1] - a[0])
for i in range(1, n - 1):
	dp[i][0] = max(0, dp[i - 1][1] - abs(a[i] - a[i + 1]))
	dp[i][1] = max(0, dp[i - 1][0] + abs(a[i] - a[i + 1]))
	maxi = max(maxi, dp[i][0], dp[i][1])
print(maxi)


lectura = lambda : map(int, input().split())
n = list(lectura())[0]
lista = list(lectura())
fDescrita = 0
alt1 = 1
maxV1 = 0
maxV2 = 0
C1 = 0
C2 = 0
for i in range(0, n - 1):
	fDescrita = abs(lista[i] - lista[i + 1]) * alt1
	maxV1 = max(maxV1 + fDescrita, fDescrita)
	maxV2 = max(maxV2, maxV1)
	alt1 = alt1 * -1
C1 = maxV2
maxV1 = 0
maxV2 = 0
alt1 = 1
for i in range(1, n - 1):
	fDescrita = abs(lista[i] - lista[i + 1]) * alt1
	maxV1 = max(maxV1 + fDescrita, fDescrita)
	maxV2 = max(maxV2, maxV1)
	alt1 = alt1 * -1
C2 = maxV2
print(max(C1, C2))


n = int(input())
a = input().split()
arr = [abs(int(a[i]) - int(a[i + 1])) * (-1) ** i for i in range(n - 1)]
maximum = 0
summ = 0
for j in arr:
	if j > 0 or abs(j) < abs(summ):
		summ += j
	else:
		summ = 0
	maximum = max(maximum, abs(summ))
summ = 0
for k in arr[1:]:
	if k < 0 or abs(k) < abs(summ):
		summ += k
	else:
		summ = 0
	maximum = max(maximum, abs(summ))
print(maximum)


n = int(input())
a = list(map(int, input().split()))
a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
ans = t1 = t2 = 0
for i in a:
	(t1, t2) = (max(t2 + i, 0), max(t1 - i, 0))
	ans = max(ans, t1, t2)
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
	b.append(abs(a[i] - a[i + 1]))
c = []
s = 1
summ = 0
for i in range(n - 1):
	summ += s * b[i]
	s = -s
	c.append(summ)
c.sort()
if c[0] < 0:
	print(c[n - 2] - c[0])
else:
	print(c[n - 2])


n = int(input())
w = [int(k) for k in input().split()]
a = []
for j in range(1, len(w)):
	a.append(abs(w[j] - w[j - 1]))
(b, c) = ([], [])
for j in range(len(a)):
	if j % 2:
		b.append(-a[j])
		c.append(a[j])
	else:
		b.append(a[j])
		c.append(-a[j])
res = 0
(x, y) = ([], [])
q = 0
for j in b:
	x.append(q)
	q += j
x.append(q)
q = 0
for j in c:
	y.append(q)
	q += j
y.append(q)
(mx, mn) = (0, 0)
for j in x:
	mx = max(mx, j)
	mn = min(mn, j)
	res = max(res, mx - mn)
(mx, mn) = (0, 0)
for j in y:
	mx = max(mx, j)
	mn = min(mn, j)
	res = max(res, mx - mn)
print(res)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(n - 1):
	if i % 2 == 0:
		d.append(abs(a[i + 1] - a[i]))
	else:
		d.append(-abs(a[i + 1] - a[i]))
ans = -10 ** 18
m = 0
acc = 0
for i in range(n - 1):
	acc += d[i]
	ans = max(ans, acc - m)
	if i % 2 == 1:
		m = min(m, acc)
d = list(map(lambda x: -x, d))
m = 0
acc = 0
for i in range(1, n - 1):
	acc += d[i]
	ans = max(ans, acc - m)
	if i % 2 == 0:
		m = min(m, acc)
print(ans)


n = int(input())
nums = input().split(' ')
sumas = [0] * (n + 1)
dp = [[0] * 2 for _ in range(n + 1)]
res = -100000000000.0
for x in range(0, n):
	if x > 0:
		sumas[x] = abs(int(nums[x]) - int(nums[x - 1]))
for x in range(1, n + 1):
	dp[x][0] = max(sumas[x], dp[x - 1][1] + sumas[x])
	dp[x][1] = max(-sumas[x], dp[x - 1][0] - sumas[x])
	res = max(max(dp[x][0], dp[x][1]), res)
print(res)


import sys
n = int(input())
l = list(map(int, input().split()))
a = [0] * (n - 1)
for i in range(n - 1):
	a[i] = abs(l[i] - l[i + 1]) * (-1) ** i
if n == 2:
	print(a[0])
	sys.exit()
a1 = [0] * (n - 2)
for i in range(1, n - 1):
	a1[i - 1] = abs(l[i] - l[i + 1]) * (-1) ** (i - 1)
ans = a[0]
cur = a[0]
for i in range(1, n - 1):
	cur = max(cur + a[i], a[i])
	ans = max(ans, cur)
ans1 = a1[0]
cur1 = a1[0]
for i in range(1, n - 2):
	cur1 = max(cur1 + a1[i], a1[i])
	ans1 = max(ans1, cur1)
print(max(ans, ans1))


from math import fabs
n = int(input())
a = list(map(int, input().split(' ')))
a.insert(0, 0)
n += 1
dpmin = [0] * n
dpmax = [0] * n
dpmin[2] = abs(a[2] - a[1])
dpmax[2] = abs(a[2] - a[1])
for i in range(3, n):
	dpmax[i] = max(abs(a[i] - a[i - 1]), abs(a[i] - a[i - 1]) - dpmin[i - 1])
	dpmin[i] = min(abs(a[i] - a[i - 1]), abs(a[i] - a[i - 1]) - dpmax[i - 1])
res = 0
for i in dpmax:
	res = max(res, i)
print(res)


n = int(input())
_l = list(map(int, input().split()))
l = [abs(_l[i] - _l[i + 1]) for i in range(n - 1)]
(p, n, res) = (0, 0, 0)
for e in l:
	_p = max(0, n + e)
	_n = max(0, p - e)
	(p, n) = (_p, _n)
	res = max(p, n, res)
print(res)


n = int(input())
a = list(map(int, input().split()))
d1 = []
d2 = []
for i in range(n - 1):
	if i % 2 == 0:
		d1.append(abs(a[i] - a[i + 1]))
		d2.append(-1 * abs(a[i] - a[i + 1]))
	else:
		d1.append(-1 * abs(a[i] - a[i + 1]))
		d2.append(abs(a[i] - a[i + 1]))
s1 = [0 for i in range(n)]
s2 = [0 for i in range(n)]
s1[0] = d1[0]
s2[0] = d2[0]
ans = max(s1[0], s2[0])
for i in range(1, n - 1):
	s1[i] = max(d1[i], d1[i] + s1[i - 1])
	s2[i] = max(d2[i], d2[i] + s2[i - 1])
	ans = max(s1[i], s2[i], ans)
print(ans)


n = int(input())
arr = list(map(int, input().split()))
even = [0 for i in range(n)]
odd = [0 for i in range(n)]
diff = []
for i in range(n - 1):
	diff.append(abs(arr[i] - arr[i + 1]))
for i in range(len(diff)):
	even[i] = max(diff[i], diff[i] + odd[i - 1])
	odd[i] = max(-diff[i], -diff[i] + even[i - 1])
print(max(max(even), max(odd)))


n = int(input())
a = list(map(int, input().split()))
dif = list()
for i in range(n - 1):
	if i % 2 == 0:
		dif.append(int(abs(a[i] - a[i + 1])))
	else:
		dif.append(-1 * int(abs(a[i] - a[i + 1])))
pref = list()
for i in range(len(dif)):
	if i == 0:
		pref.append(dif[0])
	else:
		pref.append(pref[i - 1] + dif[i])
mx = 0
mn = 0
mxidx = 0
mnidx = 0
for i in range(len(pref)):
	if pref[i] > mx:
		mx = pref[i]
		mxidx = i
	if pref[i] < mn:
		mn = pref[i]
		mnidx = i
print(mx - mn)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
z = []
for i in range(n - 1):
	z.append(abs(l[i] - l[i + 1]))
ans = 0
(a, b) = (0, 0)
for i in z:
	(a, b) = (max(b + i, 0), max(a - i, 0))
	ans = max(ans, a + b)
print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = -10 ** 9 - 1
mini = 0
temp = 0
for i in range(n - 1):
	if i % 2 == 0:
		temp += abs(a[i] - a[i + 1])
	else:
		temp -= abs(a[i] - a[i + 1])
	mini = min(mini, temp)
	ans = max(ans, temp - mini)
mini = 0
temp = 0
for i in range(1, n - 1):
	if i % 2 == 0:
		temp -= abs(a[i] - a[i + 1])
	else:
		temp += abs(a[i] - a[i + 1])
	mini = min(mini, temp)
	ans = max(ans, temp - mini)
print(ans)


from math import inf
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(len(a) - 1):
	b.append(abs(a[i] - a[i + 1]))
mini = -inf
dp = [[0 for i in range(2)] for j in range(len(b))]
dp[0][0] = b[0]
dp[0][1] = 0
for i in range(1, len(b)):
	dp[i][0] = max(dp[i - 1][1] + b[i], b[i])
	dp[i][1] = dp[i - 1][0] - b[i]
maxi = -inf
for i in range(len(b)):
	maxi = max(maxi, max(dp[i][0], dp[i][1]))
print(maxi)


n = int(input())
arr = list(map(int, input().split()))
ls = [abs(arr[i + 1] - arr[i]) * (-1) ** (i % 2) for i in range(n - 1)]
ls1 = [abs(arr[i + 1] - arr[i]) * (-1) ** (1 - i % 2) for i in range(n - 1)]
su = 0
s = 0
for i in ls:
	su += i
	if su < 0:
		su = 0
	else:
		s = max(s, su)
su = 0
for j in ls1:
	su += j
	if su < 0:
		su = 0
	else:
		s = max(su, s)
print(s)


n = int(input())
a = list(map(int, input().split()))
d = [[] for i in range(2)]
pre = a[0]
mi = 1
for i in range(1, n):
	d[0].append(mi * abs(pre - a[i]))
	d[1].append(-mi * abs(pre - a[i]))
	pre = a[i]
	mi *= -1
m = len(d[0])
L = [[0] * m for i in range(2)]
R = [[0] * m for i in range(2)]
L[0][0] = d[0][0]
L[1][0] = d[1][0]
R[0][0] = d[0][0]
R[1][0] = d[1][0]
for k in range(2):
	for i in range(1, m):
		if L[k][i - 1] >= R[k][i - 1]:
			L[k][i] = L[k][i - 1]
		else:
			L[k][i] = R[k][i - 1]
		if R[k][i - 1] + d[k][i] < d[k][i]:
			R[k][i] = d[k][i]
		else:
			R[k][i] = R[k][i - 1] + d[k][i]
if L[0][-1] > R[0][-1]:
	num1 = L[0][-1]
else:
	num1 = R[0][-1]
if L[1][-1] > R[1][-1]:
	num2 = L[1][-1]
else:
	num2 = R[1][-1]
print(max(num1, num2))


n = int(input())
a = list(map(int, input().split()))
b = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
(p, q, r) = (0, 0, 0)
for i in b:
	_p = max(0, q + i)
	_q = max(0, p - i)
	(p, q) = (_p, _q)
	r = max(p, q, r)
print(r)


n = int(input())
a = list(map(int, input().split()))
d = [abs(a[i] - a[i + 1]) * (-1) ** i for i in range(n - 1)]
maxsum1 = 0
sum1 = 0
for di in d:
	if di > 0 or abs(di) < abs(sum1):
		sum1 += di
	else:
		sum1 = 0
	maxsum1 = max(maxsum1, abs(sum1))
sum1 = 0
for di in d[1:]:
	if di < 0 or abs(di) < abs(sum1):
		sum1 += di
	else:
		sum1 = 0
	maxsum1 = max(maxsum1, abs(sum1))
print(maxsum1)


def max_sum(a):
	(s, ans) = (0, 0)
	for i in a:
		s += i
		ans = max(s, ans)
		s = max(0, s)
	return ans
n = int(input())
(*a,) = map(int, input().split())
a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
b = [-1 * a[i] if i & 1 else a[i] for i in range(n - 1)]
a = [a[i] if i & 1 else -1 * a[i] for i in range(n - 1)]
print(max(max_sum(a), max_sum(b)))


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(len(a) - 1):
		b.append(abs(a[i] - a[i + 1]))
	max_odd = b[0]
	max_even = 0
	all_values = [max_odd, max_even]
	for bi in b[1:]:
		new_odd = max(max_even + bi, bi)
		new_even = max(max_odd - bi, 0)
		max_odd = new_odd
		max_even = new_even
		all_values += [max_odd, max_even]
	print(max(all_values))
main()


n = int(input())
arr = list(map(int, input().split()))
diff = [abs(arr[i] - arr[i - 1]) for i in range(1, n)]
(res0, res1, res, curr_sum) = (-2000000000.0, 0, -2000000000.0, 0)
for i in range(n - 1):
	curr_sum += diff[i] * (1 if i % 2 == 0 else -1)
	res = max(res, curr_sum - res1, res0 - curr_sum)
	if i % 2 == 0:
		res0 = max(res0, curr_sum)
	else:
		res1 = min(res1, curr_sum)
print(res)


import math
n = int(input())
seq = [0] + list(map(int, input().split()))
cum = [0] + list((abs(seq[i - 1] - seq[i]) if i > 1 else 0 for i in range(1, n + 1)))
mx = -math.inf
eve = [0] * len(cum)
odd = [0] * len(cum)
for i in range(2, len(cum)):
	eve[i] = max(cum[i], odd[i - 1] + cum[i])
	odd[i] = max(-cum[i], eve[i - 1] - cum[i])
	mx = max(mx, odd[i], eve[i])
print(mx)


from collections import defaultdict
from sys import stdin

def fun(ar):
	if len(ar) < 2:
		return 0
	(ans, cur) = (0, 0)
	for i in range(len(ar) - 1):
		if i & 1 == 0 and cur < 0:
			cur = 0
		cur += abs(ar[i + 1] - ar[i]) * (-1 if i & 1 else 1)
		ans = max(ans, cur)
	return ans

def main():
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	print(max(fun(ar), fun(ar[1:])))
main()


import os, sys
from io import BytesIO, IOBase

def kadane(lst):
	(su, ans) = (0, 0)
	for i in lst:
		su = max(0, su + i)
		ans = max(ans, su)
	return ans

def main():
	n = int(input())
	a = list(map(int, input().split()))
	ls = [pow(-1, i) * abs(a[i + 1] - a[i]) for i in range(n - 1)]
	ls1 = [-1 * ls[i] for i in range(1, len(ls))]
	print(max(kadane(ls), kadane(ls1)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
arr = list(map(int, input().strip().split()))
arr1 = [(1 - 2 * (i % 2)) * abs(arr[i] - arr[i + 1]) for i in range(n - 1)]
arr2 = [(1 - 2 * (1 - i % 2)) * abs(arr[i] - arr[i + 1]) for i in range(n - 1)]
so_far = 0
sumi = 0
for i in arr1:
	sumi += i
	if sumi < 0:
		sumi = 0
	else:
		so_far = max(sumi, so_far)
sumi = 0
for i in arr2:
	sumi += i
	if sumi < 0:
		sumi = 0
	else:
		so_far = max(sumi, so_far)
print(so_far)


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
n = it()
a = lt()
L = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
ans = [0 for _ in range(n)]
ans[0] = L[0]
for i in range(1, n - 1):
	ans[i] = max(L[i], L[i] - ans[i - 1])
	if i - 2 >= 0:
		ans[i] = max(ans[i], L[i] - L[i - 1] + ans[i - 2])
print(max(ans))


import os
import sys
from io import BytesIO, IOBase

def solve(d):
	(ma, mas) = (0, 0)
	for i in d:
		mas += i
		mas = max(mas, 0)
		ma = max(mas, ma)
	return ma

def main():
	n = int(input())
	a = list(map(int, input().split()))
	(d, c) = ([], [])
	for i in range(n - 1):
		d.append(abs(a[i] - a[i + 1]) * (-1 if i & 1 else 1))
		c.append(abs(a[i] - a[i + 1]) * (1 if i & 1 else -1))
	print(max(solve(d), solve(c)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
n = int(input())
a = list(map(int, input().split()))
c = []
for i in range(len(a) - 1):
	c.append(abs(a[i] - a[i + 1]))
p = []
q = []
for i in range(len(c)):
	p.append(c[i] * pow(-1, i))
for i in range(len(c)):
	q.append(c[i] * pow(-1, i + 1))
print(max(maxSubArraySum(p, len(p)), maxSubArraySum(q, len(q))))


n = int(input())
a = [int(i) for i in input().split()]
b = [abs(a[i] - a[i - 1]) for i in range(1, len(a))]
sm = [[0] * 2 for i in range(n)]
mn = [[0] * 2 for i in range(n + 1)]
ans = -1000000
for i in range(n - 2, -1, -1):
	if i % 2 == 0:
		sm[i][0] = b[i] + sm[i + 1][0]
		sm[i][1] = -b[i] + sm[i + 1][1]
		mn[i][1] = min(mn[i + 2][1], sm[i][1])
		ans = max(ans, sm[i][0] - mn[i + 1][0])
	else:
		sm[i][1] = b[i] + sm[i + 1][1]
		sm[i][0] = -b[i] + sm[i + 1][0]
		mn[i][0] = min(mn[i + 2][0], sm[i][0])
		ans = max(ans, sm[i][1] - mn[i + 1][1])
print(ans)


n = int(input())
l = list(map(int, input().split()))
ma = 0
p1 = 0
p2 = 0
for i in range(n - 1):
	if (i + 1) % 2 != 0:
		p1 = p1 + abs(l[i] - l[i + 1])
		p2 = p2 - abs(l[i] - l[i + 1])
		if p2 < 0:
			p2 = 0
		ma = max(p1, ma)
	else:
		p2 = p2 + abs(l[i] - l[i + 1])
		p1 = p1 - abs(l[i] - l[i + 1])
		if p1 < 0:
			p1 = 0
		ma = max(p2, ma)
print(ma)


from sys import stdin, stdout
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().strip().split(' ')))
tarr1 = [abs(arr[1] - arr[0])]
tarr2 = []
for i in range(2, n):
	tarr1.append(pow(-1, i - 1) * abs(arr[i] - arr[i - 1]))
	tarr2.append(-1 * tarr1[-1])
ans = tarr1[0]
tans = tarr1[0]
for i in tarr1[1:]:
	if tans < 0:
		tans = i
	else:
		tans += i
	ans = max(tans, ans)
if len(tarr2) > 0:
	tans = tarr2[0]
	ans = max(ans, tans)
	for i in tarr2[1:]:
		if tans < 0:
			tans = i
		else:
			tans += i
		ans = max(tans, ans)
stdout.write(str(ans) + '\n')


n = int(input())
arr = list(map(int, input().split(' ')))
arr.insert(0, 0)
diff_arr = []
end_so_far = 0
max_so_far = 0
l = 1
for i in range(2, len(arr) - 1):
	temp = abs(arr[i] - arr[i + 1])
	diff_arr.append(temp * pow(-1, i))
	end_so_far = end_so_far + diff_arr[-1]
	if end_so_far < 0:
		if i % 2 == 0:
			i = i + 1
		end_so_far = 0
	if max_so_far < end_so_far:
		max_so_far = end_so_far
even_max = max_so_far
max_so_far = 0
end_so_far = 0
for i in range(1, len(arr) - 1):
	temp = abs(arr[i] - arr[i + 1])
	diff_arr.append(temp * pow(-1, i - 1))
	end_so_far = end_so_far + diff_arr[-1]
	if end_so_far < 0:
		if i % 2 == 1:
			i = i + 1
		end_so_far = 0
	if max_so_far < end_so_far:
		max_so_far = end_so_far
odd_max = max_so_far
print(max(odd_max, even_max))


n = int(input())
a = list(map(int, input().split()))
first = [-abs(a[i] - a[i - 1]) if (i + 1) % 2 else abs(a[i] - a[i - 1]) for i in range(1, n)]
second = [abs(a[i] - a[i - 1]) if (i + 1) % 2 else -abs(a[i] - a[i - 1]) for i in range(2, n)]
mx = -10 ** 18
cur = 0
for i in range(len(first)):
	cur = first[i] + max(cur, 0)
	if i % 2 == 0:
		mx = max(mx, cur)
cur = 0
for i in range(len(second)):
	cur = second[i] + max(cur, 0)
	if i % 2 == 0:
		mx = max(mx, cur)
print(mx)


import math
import sys
n = int(input())
a = []
b = [None] * n
c = [None] * n
for x in input().split():
	a.append(int(x))
for i in range(0, n - 1):
	b[i] = c[i] = abs(a[i + 1] - a[i])
	b[i] *= math.pow(-1, i)
	c[i] *= math.pow(-1, i + 1)
maxCurrB = b[0]
maxB = b[0]
maxCurrC = c[0]
maxC = c[0]
for i in range(1, n - 1):
	maxCurrB = max(b[i], maxCurrB + b[i])
	maxB = max(maxB, maxCurrB)
	maxCurrC = max(c[i], maxCurrC + c[i])
	maxC = max(maxC, maxCurrC)
print(int(max(maxB, maxC)))


from sys import stdin, stdout

def ri():
	return map(int, input().split())
n = int(input())
a = list(ri())
b = [abs(a[i] - a[i + 1]) * (-1) ** i for i in range(n - 1)]
ans = 0
s = 0
i = 0
while i < n - 1:
	s += b[i]
	if s < 0:
		s = 0
		if i % 2 == 0:
			i += 1
	i += 1
	ans = max(s, ans)
b = [-b[i] for i in range(n - 1)]
s = 0
i = 1
while i < n - 1:
	s += b[i]
	if s < 0:
		s = 0
		if i % 2 == 1:
			i += 1
	i += 1
	ans = max(s, ans)
print(ans)


from itertools import accumulate
inf = 10 ** 9 + 1

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	ad = [abs(a[i + 1] - a[i]) for i in range(n - 1)]
	ap = [0] + list(accumulate((ai * (-1) ** i for (i, ai) in enumerate(ad))))
	(max_dif, max_mdif) = max_min_profit(ap)
	ans = max(max_dif, max_mdif)
	print(ans)

def max_min_profit(a):
	max_dif = 0
	max_mdif = 0
	min_v = max_v = 0
	for i in range(1, len(a)):
		if a[i] < min_v:
			min_v = a[i]
		else:
			max_dif = max(max_dif, a[i] - min_v)
		if a[i] > max_v:
			max_v = a[i]
		else:
			max_mdif = max(max_mdif, max_v - a[i])
	return (max_dif, max_mdif)
solve()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	n = I()
	a = LI()
	r = t = abs(a[0] - a[1])
	for i in range(3, n, 2):
		t -= abs(a[i - 1] - a[i - 2])
		if t < 0:
			t = 0
		t += abs(a[i] - a[i - 1])
		if r < t:
			r = t
	if n < 3:
		return r
	t = abs(a[1] - a[2])
	if r < t:
		r = t
	for i in range(4, n, 2):
		t -= abs(a[i - 1] - a[i - 2])
		if t < 0:
			t = 0
		t += abs(a[i] - a[i - 1])
		if r < t:
			r = t
	return r
print(main())


def getNum():
	inp = input()
	return int(inp)

def getArrNum():
	inp = input()
	A = [int(x) for x in inp.split(' ')]
	return A

def getMaximal(arr):
	best = 0
	curBest = 0
	for x in arr:
		if curBest >= 0:
			curBest += x
		else:
			curBest = x
		best = max(best, curBest)
	return best
N = getNum()
arr = getArrNum()
odd = []
even = []
for i in range(N - 1):
	nm = abs(arr[i] - arr[i + 1])
	neg = nm * -1
	if i % 2 == 0:
		odd.append(nm)
		even.append(neg)
	else:
		odd.append(neg)
		even.append(nm)
ans = max(getMaximal(odd), getMaximal(even))
print(ans)


import sys
n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(1, n):
	d.append(abs(a[i] - a[i - 1]))
evencur = 0
sgn = 1
ans = 0
for i in range(len(d)):
	evencur += d[i] * sgn
	sgn *= -1
	ans = max(evencur, ans)
	if evencur < 0:
		evencur = 0
		sgn = 1
evencur = 0
sgn = 1
for i in range(1, len(d)):
	evencur += d[i] * sgn
	sgn *= -1
	ans = max(evencur, ans)
	if evencur < 0:
		evencur = 0
		sgn = 1
print(ans)


def f(l, r, p):
	if l > r:
		return 0
	return p[r] - p[l - 1] if l % 2 == 1 else -f(l - 1, r, p) + p[l - 1]

def main():
	read = lambda : tuple(map(int, input().split()))
	n = read()[0]
	v = read()
	p = [0]
	pv = 0
	for i in range(n - 1):
		cp = abs(v[i] - v[i + 1]) * (-1) ** i
		pv += cp
		p += [pv]
	(mxc, mxn) = (0, 0)
	(mnc, mnn) = (0, 0)
	for i in range(n):
		(cc, cn) = (f(1, i, p), f(2, i, p))
		(mxc, mxn) = (max(mxc, cc - mnc), max(mxn, cn - mnn))
		(mnc, mnn) = (min(mnc, cc), min(mnn, cn))
	return max(mxc, mxn)
print(main())


input()
numbers = [int(x) for x in input().split()]
diffs = []
(sum_odd, sum_even) = (0, 0)
for x in range(len(numbers) - 1):
	diffs.append(abs(numbers[x] - numbers[x + 1]))
_max = 0
for x in range(len(diffs)):
	aux = diffs[x]
	if x % 2 == 1:
		aux *= -1
	sum_even += aux
	sum_odd -= aux
	if sum_even < 0:
		sum_even = 0
	if sum_odd < 0:
		sum_odd = 0
	_max = max([sum_even, sum_odd, _max])
print(_max)


n = int(input())
A = list(map(int, input().split()))
B = []
for i in range(n - 1):
	B.append(abs(A[i] - A[i + 1]))
dpmin = [0] * n
dpmax = [0] * n
for i in range(n - 2, -1, -1):
	dpmax[i] = B[i]
	dpmin[i] = B[i]
	dpmin[i] = min(dpmin[i], B[i] - dpmax[i + 1])
	dpmax[i] = max(dpmax[i], B[i] - dpmin[i + 1])
print(max(dpmax))


def maxSubArraySum(a, size):
	max_so_far = -9999999999999 - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far
a = int(input())
b = list(map(int, input().split()))
dp = []
for x in range(1, a):
	dp.append(abs(b[x] - b[x - 1]))
dp1 = dp.copy()
for x in range(a - 1):
	if x % 2 != 0:
		dp[x] = -dp[x]
for x in range(1, a - 1):
	if x % 2 == 0:
		dp1[x] = -dp1[x]
j = maxSubArraySum(dp, a - 1)
h = maxSubArraySum(dp1[1:], a - 2)
print(max(j, h))


def maxSubArraySum(a, size):
	max_so_far = a[0]
	curr_max = a[0]
	for i in range(1, size):
		curr_max = max(a[i], curr_max + a[i])
		max_so_far = max(max_so_far, curr_max)
	return max_so_far
n = int(input())
a = list(map(int, input().split()))
aa = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
b = [aa[i] * (-1) ** i for i in range(n - 1)]
c = [aa[i] * (-1) ** (i + 1) for i in range(n - 1)]
print(max(maxSubArraySum(b, n - 1), maxSubArraySum(c, n - 1)))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
A = [0] + alele()
l = 1
Ans = -1000000000000000.0
temp = -1000000000000000.0
for i in range(1, N):
	z = abs(A[i] - A[i + 1]) * (-1) ** (i - l)
	temp = max(z, temp + z)
	Ans = max(Ans, temp)
temp = -1000000000000000.0
l = 2
temp = -1000000000000000.0
for i in range(2, N):
	z = abs(A[i] - A[i + 1]) * (-1) ** (i - l)
	temp = max(z, temp + z)
	Ans = max(Ans, temp)
print(Ans)


R = lambda : list(map(int, input().split()))
n = int(input())
a = R()
dif = [0] * (n - 1)
for i in range(n - 1):
	dif[i] = abs(a[i] - a[i + 1]) * (1 - 2 * (i % 2))
sum = [0] * n
sum[0] = 0
for i in range(1, n):
	sum[i] = sum[i - 1] + dif[i - 1]
ma = [0] * (n - 1)
mi = [0] * (n - 1)
for i in range(n - 2, -1, -1):
	ma[i] = max(sum[i + 1], ma[i + 1] if i < n - 2 else sum[i + 1])
	mi[i] = min(sum[i + 1], mi[i + 1] if i < n - 2 else sum[i + 1])
res = 0
for i in range(n - 1):
	if i % 2 == 0:
		res = max(res, ma[i] - sum[i])
	else:
		res = max(res, -(mi[i] - sum[i]))
print(res)


n = int(input())
arr = list(map(int, input().split()))
new = []
c = 1
for i in range(n - 1):
	new.append(abs(arr[i] - arr[i + 1]) * c)
	c *= -1
s = 0
s1 = 0
m = 0
for i in range(n - 1):
	s += new[i]
	if s < 0:
		s = 0
	if i > 0:
		s1 += -new[i]
		if s1 < 0:
			s1 = 0
		m = max(m, s1)
	m = max(m, s)
print(m)


n = int(input())
a = list(map(int, input().strip().split()))
b = [0] * (n - 1)
c = [0] * (n - 1)
for i in range(n - 1):
	if i % 2 == 0:
		b[i] = abs(a[i] - a[i + 1])
	else:
		b[i] = abs(a[i] - a[i + 1]) * -1
for i in range(1, n - 1):
	if (i - 1) % 2 == 0:
		c[i] = abs(a[i] - a[i + 1])
	else:
		c[i] = abs(a[i] - a[i + 1]) * -1
d1 = [-1000000001] * (n - 1)
d2 = [-1000000001] * (n - 1)
for i in range(n - 1):
	if i > 0:
		d1[i] = max(b[i] + d1[i - 1], max(0, b[i]))
	else:
		d1[i] = max(b[i], 0)
for i in range(n - 1):
	if i > 0:
		d2[i] = max(c[i] + d2[i - 1], max(0, c[i]))
	else:
		d2[i] = max(c[i], 0)
print(max(max(d1), max(d2)))


n = int(input())
lis = list(map(int, input().split()))
ab = [abs(lis[i] - lis[i - 1]) for i in range(1, n)]
ev = od = ans = 0
for i in range(n - 1):
	if i % 2 == 0:
		ev += ab[i]
		od = max(0, od - ab[i])
	else:
		ev = max(0, ev - ab[i])
		od += ab[i]
	ans = max(ans, ev, od)
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
	b.append(abs(a[i] - a[i + 1]))
mx = -float('inf')
now = 0
for i in range(n - 1):
	now += b[i] * (-1) ** (i % 2)
	mx = max(mx, now)
	if now < 0:
		now = 0
now = 0
for i in range(1, n - 1):
	now += b[i] * (-1) ** (i % 2 + 1)
	mx = max(mx, now)
	if now < 0:
		now = 0
print(mx)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(1, n):
	b.append(abs(a[i] - a[i - 1]))
n = len(b)
for i in range(n):
	b[i] *= (-1) ** (i % 2)
ans = 0
mx = 0
mi = 0
s = 0
for i in range(n):
	s += b[i]
	ans = max(ans, max(abs(s - mx), abs(s - mi)))
	mx = max(s, mx)
	mi = min(s, mi)
print(ans)


def kadane(A):
	if len(A) == 0:
		return 0
	max_c = A[0]
	max_g = A[0]
	for i in range(1, len(A)):
		max_c = max(A[i], max_c + A[i])
		if max_c > max_g:
			max_g = max_c
	return max_g

def answer(n, A):
	b = []
	for i in range(0, n - 1):
		x = abs(A[i] - A[i + 1]) * (-1) ** i
		b.append(x)
	c = []
	for i in range(1, n - 1):
		y = abs(A[i] - A[i + 1]) * (-1) ** (i + 1)
		c.append(y)
	s1 = kadane(b)
	s2 = kadane(c)
	return max(s1, s2)
n = int(input())
arr = list(map(int, input().split()))
print(answer(n, arr))


n = int(input())
a = list(map(int, input().split()))
d = list(map(lambda i: abs(a[i] - a[i + 1]), range(n - 1)))
x = list(map(lambda i: d[i] * (-1) ** i, range(0, n - 1)))
y = list(map(lambda i: d[i] * (-1) ** (i + 1), range(0, n - 1)))
max1 = x[0]
s = 0
for l in range(0, n - 1, 1):
	s += x[l]
	max1 = max([max1, s])
	s = max([s, 0])
max2 = max1
s = 0
for l in range(1, n - 1, 1):
	s += y[l]
	max2 = max([max2, s])
	s = max([s, 0])
print(max2)


def max_subarray(numbers, k):
	best_sum = 0
	current_sum = 0
	for x in range(len(numbers)):
		if k % 2 == k:
			current_sum = max(0, current_sum + numbers[x])
		else:
			current_sum = current_sum + numbers[x]
		best_sum = max(best_sum, current_sum)
	return best_sum
n = int(input())
l = list(map(int, input().split()))
l1 = []
l2 = []
s = 1
for i in range(n - 1):
	l1.append(abs(l[i] - l[i + 1]) * s)
	l2.append(abs(l[i] - l[i + 1]) * (-1 * s))
	s = s * -1
print(max(max_subarray(l1, 0), max_subarray(l2, 1)))


import sys
import inspect
import re
import math
from collections import defaultdict
from pprint import pprint as pi
MOD = 10000000000.0 + 7
INF = 10 ** 12
n = int(input())
a = list(map(int, input().split()))
d = []
for i in range(1, n):
	d.append(abs(a[i] - a[i - 1]))
n -= 1
sum = 0
cur = 0
for i in range(n):
	cur += ((i + 1) % 2 - i % 2) * d[i]
	if cur < 0:
		cur = 0
	if cur > sum:
		sum = cur
cur = 0
for i in range(1, n):
	cur += (i % 2 - (i + 1) % 2) * d[i]
	if cur < 0:
		cur = 0
	if cur > sum:
		sum = cur
pi(sum)


read = lambda : map(int, input().split())
n = int(input())
a = list(read())
d = [0] * n
b = [0] * n
c = [0] * n
sgn = 1
for i in range(1, n):
	d[i] = abs(a[i - 1] - a[i])
	b[i] = d[i] * sgn
	c[i] = -b[i]
	sgn *= -1
s = [0] * n
for i in range(1, n):
	s[i] = s[i - 1] + b[i]
mn = ans = 0
for i in range(1, n):
	if i % 2:
		ans = max(ans, s[i] - mn)
	else:
		mn = min(mn, s[i])
for i in range(1, n):
	s[i] = s[i - 1] + c[i]
mn = 0
for i in range(1, n):
	if i % 2:
		mn = min(mn, s[i])
	else:
		ans = max(ans, s[i] - mn)
print(ans)


import math
n = int(input())
a = list(map(int, input().split()))
b = []
dp1 = []
dp2 = []
c = []
d = []
for i in range(n - 1):
	b.append(abs(a[i + 1] - a[i]))
for j in range(n - 1):
	if j % 2:
		c.append(b[j])
		d.append(-1 * b[j])
	else:
		c.append(-1 * b[j])
		d.append(b[j])
dp1.append(c[0])
dp2.append(d[0])
for i in range(1, n - 1):
	dp1.append(max(c[i], dp1[i - 1] + c[i]))
	dp2.append(max(d[i], dp2[i - 1] + d[i]))
print(max(max(dp1), max(dp2)))


import sys
inf = float('inf')
sys.setrecursionlimit(1000000)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def maxSubArraySum(a, size):
	max_so_far = -inf - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
b = []
c = []
d = -1
e = 1
for i in range(n - 1):
	b.append(abs(Arr[i] - Arr[i + 1]) * d)
	c.append(abs(Arr[i] - Arr[i + 1]) * e)
	d = -d
	e = -e
print(max(maxSubArraySum(b, n - 1), maxSubArraySum(c, n - 1)))


n = int(input())
a = list(map(int, input().split()))

def getAns(b):
	res = 0
	now = 0
	for x in b:
		if now > 0:
			now += x
		else:
			now = x
		res = max(res, now)
	return res
b = [abs(a[i] - a[i + 1]) * (-1 if i & 1 else 1) for i in range(n - 1)]
res = getAns(b)
c = [b[i] * -1 for i in range(n - 1)]
res = max(res, getAns(c))
print(res)


n = int(input())
l = tuple(map(int, input().split()))
a = []
for i in range(n - 1):
	a.append(abs(l[i] - l[i + 1]))
ev = [a[i] if i % 2 == 0 else -a[i] for i in range(n - 1)]
od = [-i for i in ev]
od[0] = 0
dp = [ev[0]]
st = ['ev']
vmax = dp[0]
evsum = evans = 0
odsum = odans = 0
for i in range(0, n - 1):
	evsum += ev[i]
	odsum += od[i]
	evans = max(evsum, evans)
	odans = max(odsum, odans)
	if evsum < 0 and i % 2 == 1:
		evsum = 0
	if odsum < 0 and i % 2 == 0:
		odsum = 0
print(max(evans, odans))


def solve():
	n = int(input())
	a = tuple(map(int, input().split()))
	d = []
	for i in range(0, n - 1):
		d.append(abs(a[i] - a[i + 1]))
	subtracted = [0 for i in range(n - 1)]
	added = [0 for i in range(n - 1)]
	if n == 2:
		print(d[0])
	else:
		added[0] = d[0]
		added[1] = d[1]
		subtracted[1] = added[0] - d[1]
		for i in range(2, n - 1):
			added[i] = max(d[i], subtracted[i - 1] + d[i])
			subtracted[i] = added[i - 1] - d[i]
		res = 0
		for i in range(n - 1):
			res = max(res, max(added[i], subtracted[i]))
		print(res)
solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def ctd(chr):
	return ord(chr) - ord('a')
mod = 998244353
INF = float('inf')

def main():
	n = N()
	arr = RLL()
	narr = []
	for i in range(n - 1):
		narr.append(abs(arr[i + 1] - arr[i]))
	res = narr[0]
	dp = [[0, 0] for _ in range(len(narr) + 1)]
	dp[1] = [narr[0], 0]
	for i in range(2, len(narr) + 1):
		dp[i][0] = dp[i - 1][1] + narr[i - 1]
		dp[i][1] = max(dp[i - 1][0] - narr[i - 1], 0)
		res = max(res, max(dp[i]))
	print(res)
main()


n = int(input())
b = list(map(int, input().split()))
s1 = 0
s2 = 0
j = 0
c = []
while j < n - 1:
	c.append(abs(b[j + 1] - b[j]))
	j += 1
j = 0
p = 0
r = 0
while j < n - 1:
	if j + 1 < n - 1:
		r = max(c[j] - c[j + 1], r + c[j] - c[j + 1])
		p = max(p, r + c[j + 1])
	else:
		r = max(c[j], r + c[j])
		p = max(p, r)
	j += 2
j = 1
r = 0
while j < n - 1:
	if j + 1 < n - 1:
		r = max(c[j] - c[j + 1], r + c[j] - c[j + 1])
		p = max(p, r + c[j + 1])
	else:
		r = max(c[j], r + c[j])
		p = max(p, r)
	j += 2
print(p)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = [abs(a[i] - a[i + 1]) for i in range(len(a) - 1)]
	ansmx = [0] * len(b)
	ansmn = [0] * len(b)
	ansmx[-1] = b[-1]
	ansmn[-1] = 0
	for i in range(1, len(b)):
		j = i - 1
		ansmx[-1 - i] = b[-1 - i] - ansmn[-i]
		ansmn[-1 - i] = min(b[-1 - i] - ansmx[-i], 0)
	print(max(ansmx))
main()


from sys import stdin, stdout
n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
first = []
second = []
ans = float('-inf')
for i in range(n - 1):
	first.append(abs(values[i] - values[i + 1]) * (-1) ** i)
	second.append(abs(values[i] - values[i + 1]) * (-1) ** (i + 1))
cnt = 0
for i in range(n - 1):
	cnt += first[i]
	ans = max(ans, cnt)
	if cnt < 0:
		cnt = 0
cnt = 0
for i in range(n - 1):
	cnt += second[i]
	ans = max(ans, cnt)
	if cnt < 0:
		cnt = 0
stdout.write(str(ans))


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
if n == 2:
	print(abs(a[0] - a[1]))
	exit()
(mx_cur1, mx_glob1) = (abs(a[0] - a[1]), abs(a[0] - a[1]))
for i in range(1, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** i
	mx_cur1 = max(mx_cur1 + tmp, tmp)
	mx_glob1 = max(mx_cur1, mx_glob1)
(mx_cur2, mx_glob2) = (abs(a[1] - a[2]), abs(a[1] - a[2]))
for i in range(2, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** (i - 1)
	mx_cur2 = max(mx_cur2 + tmp, tmp)
	mx_glob2 = max(mx_glob2, mx_cur2)
print(max(mx_glob1, mx_glob2))


n = int(input())
R = [int(i) for i in input().split()]
L = [abs(R[i] - R[i + 1]) for i in range(n - 1)]
ans = [0 for _ in range(n)]
ans[0] = L[0]
for i in range(1, n - 1):
	ans[i] = max(L[i], L[i] - ans[i - 1])
	if i - 2 >= 0:
		ans[i] = max(ans[i], L[i] - L[i - 1] + ans[i - 2])
print(max(ans))


n = int(input())
l = list(map(int, input().split()))
M = abs(l[0] - l[1])
k = 0
i = 0
t_p = 0
t_n = 0
while i < n - 1:
	k = (abs(l[i] - l[i + 1]), -abs(l[i] - l[i + 1]))[i % 2]
	t_n += k
	t_p -= k
	M = max(M, t_n, t_p)
	t_p = max(0, t_p)
	t_n = max(0, t_n)
	i += 1
print(M)


import sys
import math
import random

def __main__():
	n = int(input())
	d = [int(e) for e in input().split()]
	f = [abs(d[i + 1] - d[i]) for i in range(n - 1)]
	a = f[0]
	b = 0
	ans = a
	for i in range(1, len(f)):
		if i % 2 == 1:
			a = a - f[i]
			b = max(b + f[i], f[i])
			ans = max(ans, a, b)
		else:
			a = max(a + f[i], f[i])
			b = b - f[i]
			ans = max(ans, a, b)
	print(ans)
__main__()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def Answer(a):
	till = 0
	ans = -inf
	for i in a:
		till += i
		ans = max(till, ans)
		till = max(0, till)
	return ans
n = Int()
a = array()
a = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
n -= 1
a = [a[i] * (-1) ** i for i in range(n)]
b = [-i for i in a]
print(max(Answer(a), Answer(b)))


import sys

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	a_dif = [abs(a[i + 1] - a[i]) for i in range(n - 1)]
	a1 = [a_dif[i] * (-1) ** i for i in range(n - 1)]
	md1 = 0
	m1 = 0
	v = 0
	for i in range(n - 1):
		v += a1[i]
		if v < m1:
			m1 = v
		else:
			md1 = max(v - m1, md1)
	a2 = [a1[i] * -1 for i in range(n - 1)]
	md2 = 0
	m2 = 0
	v = 0
	for i in range(n - 1):
		v += a2[i]
		if v < m2:
			m2 = v
		else:
			md2 = max(v - m2, md2)
	ans = max(md1, md2)
	print(ans)

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None
solve()


n = int(input())
arr = list(map(int, input().split()))
diff = [abs(arr[i] - arr[i + 1]) for i in range(n - 1)]
dp = [[0, 0, 0] for _ in range(n - 1)]
dp[0][1] = diff[0]
for i in range(1, n - 1):
	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
	dp[i][1] = max(dp[i - 1][2] + diff[i], diff[i])
	dp[i][2] = dp[i - 1][1] - diff[i]
print(max(dp[n - 2][0], dp[n - 2][1], dp[n - 2][2]))


N = int(input())
L = list(map(int, input().split()))
if N == 2:
	print(abs(L[0] - L[1]))
	exit()
M = []
for i in range(N - 1):
	M.append(abs(L[i] - L[i + 1]))
M1 = [0]
flg = True
for i in range(N - 1):
	if flg:
		M1.append(M1[-1] + M[i])
	else:
		M1.append(M1[-1] - M[i])
	flg = not flg
M2 = [0]
flg = True
for i in range(1, N - 1):
	if flg:
		M2.append(M2[-1] + M[i])
	else:
		M2.append(M2[-1] - M[i])
	flg = not flg

def get_max(lst):
	maxv = 0
	minv = lst[0]
	for l in lst:
		maxv = max(maxv, l - minv)
		minv = min(minv, l)
	return maxv
ans = max(get_max(M1), get_max(M2))
print(ans)


n = int(input())
l = list(map(int, input().split(' ')))
d = []
for i in range(n - 1):
	a = 1
	if i % 2:
		a = -1
	d.append(a * abs(l[i] - l[i + 1]))
(s, b) = (0, 0)
(sm, bm) = (0, 0)
for i in range(n - 1):
	s = max(d[i], s + d[i])
	b = max(s, b)
for i in range(1, n - 1):
	sm = min(d[i], sm + d[i])
	bm = min(sm, bm)
print(max(abs(bm), abs(b)))


n = int(input())
(*a,) = map(int, input().split())
l = [abs(a[i] - a[i - 1]) for i in range(1, n)]
ans = 0
x = y = 0
for i in range(n - 1):
	t = [l[i], -l[i]][i % 2]
	x += t
	y -= t
	ans = max(ans, x, y)
	x = max(x, 0)
	y = max(y, 0)
print(ans)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def ddd():
	return collections.defaultdict(collections.defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = ii()
a = li()
if n == 2:
	print(abs(a[0] - a[1]))
	exit()
(mx_cur1, mx_glob1) = (abs(a[0] - a[1]), abs(a[0] - a[1]))
for i in range(1, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** i
	mx_cur1 = max(mx_cur1 + tmp, tmp)
	mx_glob1 = max(mx_cur1, mx_glob1)
(mx_cur2, mx_glob2) = (abs(a[1] - a[2]), abs(a[1] - a[2]))
for i in range(2, n - 1):
	tmp = abs(a[i] - a[i + 1]) * (-1) ** (i - 1)
	mx_cur2 = max(mx_cur2 + tmp, tmp)
	mx_glob2 = max(mx_glob2, mx_cur2)
print(max(mx_glob1, mx_glob2))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
d = [0] * n
c = [0] * n
e = [0] * n
x = 1
mx = 0
for i in range(1, n):
	d[i] = abs(a[i] - a[i - 1])
for i in range(1, n):
	c[i] = max(0, c[i - 1] + d[i] * x)
	e[i] = max(0, e[i - 1] + d[i] * -x)
	mx = max(mx, max(c[i], e[i]))
	x = -x
print(mx)


from sys import stdin, stdout
n = int(stdin.readline().rstrip())
a = [int(q) for q in stdin.readline().rstrip().split()]
fOdd = []
fEven = []
for i in range(n - 1):
	fOdd.append(abs(a[i] - a[i + 1]) * (-1) ** i)
	fEven.append(abs(a[i] - a[i + 1]) * (-1) ** (i - 1))
index = 0
fOddCurrent = 0
fEvenCurrent = 0
fMax = 0
while index < n - 1:
	fOddCurrent += fOdd[index]
	fEvenCurrent += fEven[index]
	if index == 0 or fEvenCurrent < 0:
		fEvenCurrent = 0
	if fOddCurrent < 0:
		fOddCurrent = 0
	fMax = max([fMax, fEvenCurrent, fOddCurrent])
	index += 1
print(fMax)


n = int(input())
a = list(map(int, input().split(' ')))
d = []
for k in range(n - 1):
	d.append(abs(a[k] - a[k + 1]))
for k in range(n - 1):
	if k % 2:
		d[k] *= -1
maxsum = 0
minsum = 0
curmax = 0
curmin = 0
for k in range(n - 1):
	if d[k] > 0:
		minsum = min(curmin, minsum)
		curmax += d[k]
		curmin += d[k]
		if curmin > 0:
			curmin = 0
	else:
		maxsum = max(maxsum, curmax)
		curmin += d[k]
		curmax += d[k]
		if curmax < 0:
			curmax = 0
maxsum = max(maxsum, curmax)
minsum = min(minsum, curmin)
print(max(abs(maxsum), abs(minsum)))


import math
n = int(input())
a = list(map(int, input().split()))

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	for i in range(len(a)):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
b = [abs(a[i] - a[i + 1]) * (-1 if i & 1 else 1) for i in range(n - 1)]
res = maxSubArraySum(b)
c = [b[i] * -1 for i in range(n - 1)]
res = max(res, maxSubArraySum(c))
print(res)


n = int(input())
num = list(map(int, input().split()))
diff = [abs(j - i) for (i, j) in zip(num, num[1:])]
s1 = 0
s2 = 0
m1 = 0
m2 = 0
for (i, x) in enumerate(diff):
	if s1 < 0:
		s1 = 0
	if s2 < 0:
		s2 = 0
	if i % 2 == 0:
		s1 += x
		s2 -= x
	else:
		s1 -= x
		s2 += x
	if s1 > m1:
		m1 = s1
	if s2 > m2:
		m2 = s2
print(max(m1, m2))


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	d = [0] * (n + 1)
	for i in range(n - 1):
		if i % 2 == 0:
			d[i + 1] = d[i] + abs(l[i] - l[i + 1])
		else:
			d[i + 1] = d[i] - abs(l[i] - l[i + 1])
	d.sort()
	print(d[n] - d[0])
solution()


n = int(input())
a = list(map(int, input().split()))
b = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
for i in range(0, n - 1, 2):
	b[i] *= -1
dp = [0] * (n - 1)
dp[0] = b[0]
for i in range(1, n - 1):
	dp[i] = max(dp[i - 1] + b[i], b[i])
ans = max(dp)
for i in range(n - 1):
	b[i] *= -1
dp = [0] * (n - 1)
dp[0] = b[0]
for i in range(1, n - 1):
	dp[i] = max(dp[i - 1] + b[i], b[i])
ans = max(ans, max(dp))
print(ans)


import math

def getMax(a, n):
	MAX = -1 * pow(10, 9)
	memoize = [[0 for x in range(2)] for y in range(n)]
	difference = [0 for x in range(n)]
	for i in range(n):
		if i > 0:
			difference[i] = abs(a[i] - a[i - 1])
	for i in range(1, n):
		memoize[i][0] = max(difference[i], memoize[i - 1][1] + difference[i])
		memoize[i][1] = max(-difference[i], memoize[i - 1][0] - difference[i])
		MAX = max(memoize[i][1], MAX)
		MAX = max(memoize[i][0], MAX)
	return MAX
n = int(input())
a = [int(x) for x in input().split()]
print(getMax(a, n))


import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input().strip('\n'))
si = lambda : input().strip('\n')
dgl = lambda : list(map(int, input().strip('\n')))
f = lambda : map(int, input().strip('\n').split())
il = lambda : list(map(int, input().strip('\n').split()))
ls = lambda : list(input().strip('\n'))
lsi = lambda : [int(i) for i in ls()]
let = 'abcdefghijklmnopqrstuvwxyz'

def kadaneneg(arr, n):
	mx = -10 ** 16
	mxend = 0
	for i in range(n):
		mxend += arr[i]
		if mxend > mx:
			mx = mxend
		if mxend < 0:
			mxend = 0
	return mx
for _ in range(1):
	n = ii()
	l = il()
	for i in range(n - 1):
		if i & 1:
			l[i] = -1 * abs(l[i] - l[i + 1])
		else:
			l[i] = abs(l[i] - l[i + 1])
	l = l[:n - 1]
	l2 = [-1 * i for i in l]
	mx1 = kadaneneg(l[:n - 1], n - 1)
	mx2 = kadaneneg(l2[:n - 1], n - 1)
	print(max(mx1, mx2))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
n = test
A = Neo()

def maxSubArray(A):
	curSum = maxSum = A[0]
	for num in A[1:]:
		curSum = max(num, curSum + num)
		maxSum = max(maxSum, curSum)
	return maxSum
A1 = [-10 ** 9]
A2 = [abs(A[0] - A[1])]
for i in range(1, n - 1):
	t = abs(A[i] - A[i + 1])
	if i % 2:
		A1.append(t)
		A2.append(-t)
	else:
		A1.append(-t)
		A2.append(t)
print(max(maxSubArray(A1), maxSubArray(A2)))


import math as mt
import sys
import bisect
input = sys.stdin.readline

def takeSecond(elem):
	return elem[1]

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def kadane(l):
	maxim = sum(l[:])
	curr = 0
	for i in range(len(l)):
		curr += l[i]
		maxim = max(curr, maxim)
		if curr < 0:
			curr = 0
	return maxim
t = 1
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	ch = 0
	for i in range(n - 1):
		l1.append(abs(l[i + 1] - l[i]))
		if ch % 2 != 0:
			l1[-1] *= -1
		ch += 1
	maxi = kadane(l1)
	ch = 0
	for i in range(1, n - 1):
		l1[i] *= -1
	maxi = max(maxi, kadane(l1[1:]))
	print(maxi)


import sys
input = sys.stdin.readline
n = int(input())
l = input().split()
li = [int(i) for i in l]
l = []
for i in range(1, n):
	l.append(abs(li[i] - li[i - 1]) * pow(-1, i))
dp = [0 for i in range(n - 1)]
dp[0] = l[0]
for i in range(1, n - 1):
	dp[i] = max(l[i], l[i] + dp[i - 1])
maxa = 0
for i in dp:
	maxa = max(maxa, i)
for i in range(n - 1):
	l[i] = -l[i]
dp = [0 for i in range(n - 1)]
dp[0] = l[0]
for i in range(1, n - 1):
	dp[i] = max(l[i], l[i] + dp[i - 1])
for i in dp:
	maxa = max(maxa, i)
print(maxa)


def max_subarray(A):
	max_ending_here = max_so_far = A[0]
	for x in A[1:]:
		max_ending_here = max(x, max_ending_here + x)
		max_so_far = max(max_so_far, max_ending_here)
	return max_so_far
n = int(input())
a = [int(v) for v in input().split()]
b = [abs(a[i] - a[i + 1]) * (-1) ** i for i in range(n - 1)]
print(max(max_subarray(b), max_subarray([-v for v in b])))


n = int(input())
arr = list(map(int, input().split()))

def function(n, arr):
	dp = {}
	for i in range(1, n):
		(temp, dp[i]) = (abs(arr[i] - arr[i - 1]), {})
		if i == 1:
			(dp[i][0], dp[i][1]) = (temp, 0)
		else:
			dp[i][0] = max(dp[i - 1][1], 0) + temp
			dp[i][1] = dp[i - 1][0] - temp
	Max = dp[1][0]
	for i in range(2, n):
		Max = max(Max, dp[i][0], dp[i][1])
	return Max
print(function(n, arr))


n = int(input())
a = [int(i) for i in input().split()]
b = [abs(a[i] - a[i + 1]) for i in range(n - 1)]
n -= 1

def fn(i0):
	f0 = 0
	ans = 0
	for i in range(i0, n):
		if i - i0 & 1:
			f0 -= b[i]
			if f0 < 0:
				f0 = 0
		else:
			f0 += b[i]
			ans = max(ans, f0)
	return ans
ans = max(fn(0), fn(1))
print(ans)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = getInts()
	diffs = [pow(-1, j) * abs(A[j] - A[j + 1]) for j in range(N - 1)]
	curr = 0
	P = []
	for d in diffs:
		curr += d
		P.append(curr)
	min_x = min(P)
	max_x = max(P)
	return max(abs(max_x), abs(min_x), abs(max_x - min_x))
print(solve())


n = int(input())
a = list(map(int, input().split(' ')))

def sign(n):
	return [1, -1][n % 2]
b1 = [abs(a[i] - a[i - 1]) for i in range(1, len(a))]
b1 = [sign(i) * b1[i] for i in range(len(b1))]
b2 = [-x for x in b1]
max_ending_here = b1[0]
max_so_far = b1[0]
for (i, x) in enumerate(b1):
	if i == 0:
		continue
	if i % 2 == 1:
		max_ending_here += x
	elif x > max_ending_here + x:
		max_ending_here = x
	else:
		max_ending_here += x
	max_so_far = max(max_so_far, max_ending_here)
b1 = b2
max_ending_here = b1[0]
max_so_far2 = b1[0]
for (i, x) in enumerate(b1):
	if i == 0:
		continue
	if i % 2 == 0:
		max_ending_here += x
	elif x > max_ending_here + x:
		max_ending_here = x
	else:
		max_ending_here += x
	max_so_far2 = max(max_so_far2, max_ending_here)
print(max(max_so_far, max_so_far2))


from sys import stdin
inf = float('inf')
(N,) = map(int, stdin.readline().split())
A = list(map(int, stdin.readline().split()))
diffodd = [0] * N
diffeven = [0] * N
for i in range(1, N):
	v = abs(A[i - 1] - A[i])
	if i % 2 == 1:
		diffodd[i] = v
		diffeven[i] = -v
	else:
		diffeven[i] = v
		diffodd[i] = -v
for i in range(1, N):
	diffodd[i] += diffodd[i - 1]
	diffeven[i] += diffeven[i - 1]
best_startodd = 0
best_starteven = 0
best_sum = -inf
for end in range(1, N):
	best_sum = max(best_sum, diffodd[end] - diffodd[best_startodd], diffeven[end] - diffeven[best_starteven])
	if diffodd[end] < diffodd[best_startodd]:
		best_startodd = end
	if diffeven[end] < diffeven[best_starteven]:
		best_starteven = end
print(best_sum)


n = int(input())
l = list(map(int, input().split()))
arr = []
for i in range(n - 1):
	if i % 2 == 0:
		arr.append(abs(-l[i + 1] + l[i]))
	else:
		arr.append(-abs(-l[i + 1] + l[i]))
arr1 = []
for i in range(n - 1):
	if i % 2 == 1:
		arr1.append(abs(-l[i + 1] + l[i]))
	else:
		arr1.append(-abs(-l[i + 1] + l[i]))
pre1 = [arr[0]]
pre2 = [arr1[0]]
for i in range(1, len(arr)):
	pre1.append(max(pre1[-1] + arr[i], arr[i]))
	pre2.append(max(pre2[-1] + arr1[i], arr1[i]))
print(max(max(pre1), max(pre2)))