def printindex(n,arr):
# n = int(input())
# arr = list(map(int,input().split(' ')))
li1=[]
li2=[]
for i in range(n):
if(arr[i]<0):
li1.append(i)
else:
li2.append(i)
index = 0
for i in li2:
for j in li1:
if abs(arr[i]>abs(arr[j])):
index +=abs(j-i)*abs(arr[j])
arr[i] = arr[i] -abs(arr[j])
arr[j] =0
else:
index +=abs(j-i)*abs(arr[i])
arr[j] = arr[j]+arr[i]
arr[i]=0
break
return index
# print(index)
if __name__ == '__main__':
test1 = {'l1': [5], 'l2': [5, -4, 1, -3,1], 'result': [9]}
# test2 = {'l1': [2, 2], 'l2': [4, 6], 'result': [4 ,2]}
test = [test1]
count = 0
for t in test:
if printindex(t['l1'], t['l2']) == t['result']:
count += 1
else:
print('l1:', t['l1'], '\nl2:', t['l2'], '\nOutput:', printindex(t['l1'], t['l2']), '\nExpect:',
t['result'])
print('Case通过率:', count * 100 / len(test), '%')