Files
PS/boj/11501.py
Gyubin Han 2600340c03 first commit
from old repository to a new repository
2024-04-30 16:59:10 +09:00

18 lines
248 B
Python

import sys
input=sys.stdin.readline
t=int(input().rstrip())
for _ in range(t):
d=int(input().rstrip())
arr=list(map(int,input().rstrip().split()))
mx=0
s=0
for i in range(d):
a=arr.pop()
if mx<a:
mx=a
else:
s+=(mx-a)
print(s)