import sys
N = int(input())
tmp = list(map(int, sys.stdin.readline()[:-1].split(' ')))
visit = [False] * N
nodes = []
max_value = 0
def dfs():
global max_value
if len(nodes) == N:
value = 0
for j in range(1, N):
value += abs(nodes[j] - nodes[j-1])
if max_value < value:
max_value = value
return
for i in range(N):
if not visit[i]:
nodes.append(tmp[i]); visit[i] = True
dfs()
nodes.pop(); visit[i] = False
dfs()
print(max_value)