Buggy python submission (verdict: Time Limit Exceeded):
#5_numpy で最後は計算
import numpy as np

int_n = int(input())
list_x = list(map(int, input().split()))
 

list_x_left = list_x
list_calc_minus = list()
 
while len(list_x_left) != 0:
  
  int_list_x_prosess_len = len(list_x_left) - list_x_left.index(max(list_x_left))
  int_max_list_x_prosess = max(list_x_left)
  list_x_left = list_x_left[:list_x_left.index(max(list_x_left))]
  
  [list_calc_minus.insert(0, int_max_list_x_prosess) for i in range(int_list_x_prosess_len)]
  
#print(sum([x - y for (x, y) in zip(list_calc_minus, list_x)]))

print((np.array(list_calc_minus) - np.array(list_x)).sum())
 

Fixed submission:
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)

Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
list_x = list(map(int, input().split()))

int_sum = 0
list_calc_minus_2 = list()

#print([max(list_x[0:len(list_x)-i]) for i in range(len(list_x))])

for i in range(len(list_x)):
  #list_calc_minus_2.insert(0, max(list_x[0:len(list_x)-i]))
  int_sum = int_sum + max(list_x[0:len(list_x)-i]) - list_x[len(list_x)-i-1]
#print(list_calc_minus_2)

#print(sum([x - y for (x, y) in zip(list_calc_minus_2, list_x)]))
print(int_sum)


Fixed submission:
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)

Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
list_x = list(map(int, input().split()))


list_calc_minus_2 = list()

#print([max(list_x[0:len(list_x)-i]) for i in range(len(list_x))])

for i in range(len(list_x)):
  list_calc_minus_2.insert(0, max(list_x[0:len(list_x)-i]))
  
#print(list_calc_minus_2)

print(sum([x - y for (x, y) in zip(list_calc_minus_2, list_x)]))


Fixed submission:
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)

Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
list_x = list(map(int, input().split()))

#print(max(list_x))

#同じ値には、最小のインデックスを返す
#print(list_x.index(max(list_x)))

#int_plus = 0
list_x_left = list_x
list_calc_minus = list()

while len(list_x_left) != 0:
  #list_x_prosess = list_x_left[list_x_left.index(max(list_x_left)):]
  
  int_list_x_prosess_len = len(list_x_left) - list_x_left.index(max(list_x_left))
  int_max_list_x_prosess = max(list_x_left)
  list_x_left = list_x_left[:list_x_left.index(max(list_x_left))]
  
  [list_calc_minus.insert(0, int_max_list_x_prosess) for i in range(int_list_x_prosess_len)]
  
  ##  print(sum([max(list_x_prosess)-i for i in list_x_prosess]))
  #int_plus = int_plus + sum([max(list_x_prosess)-i for i in list_x_prosess])
#
  ##  print(list_x_left, list_x_prosess)
  
#print(int_plus)
#print([x - y for (x, y) in zip(list_calc_minus, list_x)])
print(sum([x - y for (x, y) in zip(list_calc_minus, list_x)]))



Fixed submission:
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)

Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
list_x = list(map(int, input().split()))

#print(max(list_x))

#同じ値には、最小のインデックスを返す
#print(list_x.index(max(list_x)))

int_plus = 0
list_x_left = list_x

while len(list_x_left) != 0:
  list_x_prosess = list_x_left[list_x_left.index(max(list_x_left)):]
  list_x_left = list_x_left[:list_x_left.index(max(list_x_left))]
  
  #  print(sum([max(list_x_prosess)-i for i in list_x_prosess]))
  int_plus = int_plus + sum([max(list_x_prosess)-i for i in list_x_prosess])

  #  print(list_x_left, list_x_prosess)
print(int_plus)

Fixed submission:
int_n = int(input())
list_a = list(map(int, input().split()))

#print(int_n, list_a)

int_tmp_highet = 0
int_count = 0
for i in list_a:
  if i > int_tmp_highet:
    int_tmp_highet = i
  else:
    int_count = int_count + int_tmp_highet - i
  #print(int_count)

print(int_count)