kolvo = int(input()) giroda = set(map(int, input().split())) print((max(giroda) - min(giroda)) * 2)