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: competition

Starter code:

Solutions:
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"]

# print(a)
# print(ev)
# print(od)

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(evans, odans)

print(max(evans, odans))


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"]

# print(a)
# print(ev)
# print(od)

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(evans, odans)

print(max(evans, odans))


def f(a):
    c, v, m = 0, 0, 1
    for i in range(len(a) - 1):
        x = m * abs(a[i] - a[i + 1])
        c = max(c + x, x)
        v = max(v, c)
        m *= -1
    return v
n, a = int(input()), list(map(int, input().split()))
print(max(f(a), f(a[1:])))

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


def __starting_point():
    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)



    

__starting_point()

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
    else:
        if 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
    else:
        if 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))


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)))



n=int(input())
a=list(map(int, input().split()))
arr=[abs(a[i]-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=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()))
b = []
f = 1
for i in range(len(a) - 1):
    b.append(abs(a[i] - a[i + 1]) * f)
    f *= -1
max1, max2 = 0, 0
a1, a2 = 0, 0
for i in range(n - 1):
    if a1 + b[i] > 0:
        a1 += b[i]
    else:
        a1 = 0
    max1 = max(a1, max1)
    if a2 - b[i] > 0:
        a2 -= b[i]
    else:
        a2 = 0
    max2 = max(a2, max2)
print(max(max1, max2))


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)))


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()))

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))



# Made By Mostafa_Khaled


# n, m = [int(x) for x in input().split(" ")]
# s = set()
# ls = [0]*(n+1)
# in_C = input().split(" ")
#
# for x in range(len(in_C)-1, -1, -1):
#     s.add(int(in_C[x]))
#     ls[x+1] = len(s)
# [print(ls[int(input())]) for i in range(m)]
#
# in_x = input()
# n = list(in_x)
# length = len(n)
# counter = 0
# counter_2 = 0
# for _ in range(length):
#     temp = n[:]
#     if counter > 0:
#         temp.pop(counter)
#     counter += 1
#     for j in range(0, len(temp)):
#         if j > 0:
#             temp.pop((length - 1) - j)
#         num = int("".join(temp))
#         if num % 8 == 0:
#             print(f"YES\n{num}")
#             return
#     temp = n[:]
#     if counter_2 > 0:
#         temp.pop(counter_2)
#     counter_2 += 1
#     # print(temp)
#     for j in range(len(temp), 1, -1):
#         temp.pop(j - len(temp))
#         num = (int("".join(temp)))
#         # print(num)
#         if num % 8 == 0:
#             print(f"YES\n{num}")
#             return
# print("NO")
n = int(input())
nums = input().split(" ")
sumas = [0] * (n+1)
dp = [[0] * 2 for _ in range(n+1)]
res = -1e11
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)

# n, m = [int(x) for x in input().split(" ")]
# s = set()
# ls = [0]*(n+1)
# in_C = input().split(" ")
#
# for x in range(len(in_C)-1, -1, -1):
#     s.add(int(in_C[x]))
#     ls[x+1] = len(s)
# [print(ls[int(input())]) for i in range(m)]
#
# in_x = input()
# n = list(in_x)
# length = len(n)
# counter = 0
# counter_2 = 0
# for _ in range(length):
#     temp = n[:]
#     if counter > 0:
#         temp.pop(counter)
#     counter += 1
#     for j in range(0, len(temp)):
#         if j > 0:
#             temp.pop((length - 1) - j)
#         num = int("".join(temp))
#         if num % 8 == 0:
#             print(f"YES\n{num}")
#             return
#     temp = n[:]
#     if counter_2 > 0:
#         temp.pop(counter_2)
#     counter_2 += 1
#     # print(temp)
#     for j in range(len(temp), 1, -1):
#         temp.pop(j - len(temp))
#         num = (int("".join(temp)))
#         # print(num)
#         if num % 8 == 0:
#             print(f"YES\n{num}")
#             return
# print("NO")

n = int(input())
nums = input().split(" ")
sumas = [0] * (n+1)
dp = [[0] * 2 for _ in range(n+1)]
res = -1e11
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)

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 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))

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)


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)
    #print(fDescrita,maxV1,maxV2)
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)
    #print(fDescrita,maxV1,maxV2)
C2=maxV2
print(max(C1,C2))

import math

input()
seq = [0] + [ int(i) for i in input().split() ]
cum = [0] + [ abs(seq[i - 1] - seq[i]) if i > 1 else 0 for i in range(1, len(seq)) ]

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)



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,=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)

#	!/bin/env python3
#	encoding: UTF-8


#	✪ H4WK3yE乡
#	Mohd. Farhan Tahir
#	Indian Institute Of Information Technology and Management,Gwalior

#	Question Link
#	https://codeforces.com/problemset/problem/788/A
#

# ///==========Libraries, Constants and Functions=============///


import sys

inf = float("inf")
mod = 1000000007


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


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


def input(): return sys.stdin.readline()

# ///==========MAIN=============///


def main():
    n = int(input())
    arr = get_array()
    ans = 0
    prefix_odd = [0]*n
    for i in range(n-1):
        prefix_odd[i] = abs(arr[i+1]-arr[i])*pow(-1, i)
    prefix_even = [0]*n
    for i in range(n-1):
        prefix_even[i] = abs(arr[i+1]-arr[i])*pow(-1, i+1)

    curr_mx, mx = prefix_odd[0], prefix_odd[0]
    for i in range(1, n):
        curr_mx = max(prefix_odd[i], prefix_odd[i]+curr_mx)
        mx = max(curr_mx, mx)

    curr_mx = prefix_even[0]
    for i in range(1, n):
        curr_mx = max(prefix_even[i], prefix_even[i]+curr_mx)
        mx = max(curr_mx, mx)
    print(mx)


def __starting_point():
    main()

__starting_point()