본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬]5054번 주차의 신

by 현장 2021. 7. 9.

-코드

for _ in range(int(input())):
    n = int(input())
    shop = sorted(list(map(int, input().split())))
    r = 0
    for i in range(n - 1):
        r += shop[i + 1] - shop[i]
    print(r * 2)