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