n = int(input()) c = list(map(int, input().split())) print(2*(max(c)-min(c)))