DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.
	You are given the information of DevuLand 
	by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village. 
	Otherwise, it means that are -D[i] 
	dinosaurs in that village.

	It is also guaranteed that total number of villagers in DevuLand is equal to total number of dinosaurs.

Once dinosaurs got very hungry and started eating villagers. Frightened villagers gathered immediately and met their Sarpanch Deviji. Deviji, being a very daring and negotiable person, met to the head
of dinosaurs. Soon both parties called a truce. It was decided that the villagers will provide laddus to 
the dinosaurs. So everyday, each villager will take exactly one laddu to one of the dinosaurs in such a way that no dinosaur remains hungry (note that this is possible because number of villagers is the same as the number of dinosaurs).

Actually, carrying laddus is a quite a tough job. Villagers have to use a bullock cart for that. It takes one unit of grass a bullock to 
carry a cart with 1 laddu for 1 kilometre. Laddus used to be very heavy in DevuLand, so a bullock cart can not carry more than one laddu.

It is also given distance between village indexed i and j is |j - i| (the absolute value) kilometres.

Now villagers sat down and found a strategy to feed laddus to dinosaurs so that they need to buy the least amount of grass from the nearby market. 
They are not very good in 
calculations, please find out what is the minimum number of units of grass they need to buy.

-----Input-----

First line of the input contains an integer T denoting number of test cases.

For each test case, there are two lines. 

First line contains a single integer denoting n: number of villages. 

Second line contains n space separated integers denoting the array D.

-----Output-----

For each test case, print a single line containing the integer corresponding to answer of the problem.

-----Constraints-----

-  1 ≤ T ≤ 10^5 
-  1 ≤ n ≤ 10^5 
-  -10^4 ≤ D[i] ≤ 10^4 
-  Sum of n over all the test cases will be ≤ 10^6 
-  It is guaranteed that sum of D[i] is zero for a single test case which ensures that there are equal number of villagers and dinosaurs. 

-----Example-----
Input:
3
2
5 -5
2
-5 5
3
1 2 -3
Output:
5
5
4

-----Explanation-----
Example case 1. Each villager in village 1, need to walk 1 km to reach to the dinosaur in 2nd village.
Example case 2. Each villager in village 2, need to walk 1 km to reach to the dinosaur 1st village.
Example case 3. Each villager in village 1, need to walk 2 km to reach to the dinosaur in 3rd village whereas Each villager in village 2, 
need to walk 1 km to reach to the dinosaur in 3rd village.

Difficulty: MEDIUM_HARD

Solutions:
import sys
t = int(sys.stdin.readline())
for i in range(0, t):
	n = int(sys.stdin.readline())
	D = sys.stdin.readline().split()
	c = 0
	k = 0
	for i in range(0, n):
		c += int(D[i])
		k += abs(c)
	print(k)


from _collections import deque

def solve(A):
	lP = deque([i for i in range(len(A)) if A[i] > 0])
	lN = deque([i for i in range(len(A)) if A[i] < 0])
	s = 0
	for iN in lN:
		while A[iN] < 0:
			iP = lP[0]
			v = A[iP]
			if v >= abs(A[iN]):
				s += abs(iN - iP) * abs(A[iN])
				A[iP] -= abs(A[iN])
				A[iN] = 0
			else:
				s += abs(iN - iP) * abs(A[iP])
				A[iN] += A[iP]
				lP.popleft()
	return s
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	print(solve(A))


t = int(input())
for i in range(t):
	n = int(input())
	d = list(map(int, input().split()))
	ans = 0
	c = 0
	for j in d:
		ans += abs(c)
		c += j
	print(ans)


def read_inps():
	n = int(input())
	arr = input().split(' ')
	arr = [int(i) for i in arr]
	return (n, arr)

def solve_for(n, arr):
	grass = 0
	lad = 0
	j = 1
	lad = arr[0]
	while j < n:
		grass = grass + abs(lad)
		lad = lad + arr[j]
		j += 1
	grass = grass + abs(lad)
	return grass
T = int(input())
for i in range(T):
	ins = read_inps()
	print(solve_for(ins[0], ins[1]))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	ans = 0
	xd = 0
	for p in x:
		ans += abs(xd)
		xd += p
	print(ans)


cases = int(input())
for i in range(cases):
	vilnos = int(input())
	vills = [int(j) for j in input().split(' ')]
	grass = abs(vills[0])
	for j in range(1, vilnos):
		vills[j] += vills[j - 1]
		grass += abs(vills[j])
	print(grass)


for _ in range(int(input())):
	N = int(input())
	st = input().split()
	r = 0
	d = 0
	for x in st:
		r += abs(d)
		d += int(x)
	print(r)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	curr = 0
	ans = 0
	for x in a:
		curr += x
		ans += abs(curr)
	print(ans)


t = int(input())
for z in range(t):
	n = int(input())
	numbers = list(map(int, input().split()))
	total = 0
	answer = 0
	for i in range(n):
		total += numbers[i]
		answer += abs(total)
	print(answer)


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	grass = 0
	for i in range(n):
		if arr[i] != 0:
			grass += abs(arr[i])
			arr[i + 1] += arr[i]
			arr[i] = 0
	print(grass)