# 10819번. 차이를 최대로
fromitertoolsimportpermutationsimportsysinput=sys.stdin.readlinen=int(input())nList=list(map(int,input().split()))cList=list(permutations(nList))maxans=0forcincList:ans=0foriinrange(n-1):ans+=abs(c[i]-c[i+1])ifans>maxans:maxans=ansprint(maxans)