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

minc = min(c)
maxc = max(c)

print(abs(minc * 2) + abs(maxc * 2))