Given an array A of size N, construct a Sum Array S(of same size) such that S is equal to the sum of all the elements of A except A[i]. Your task is to complete the function SumArray(A, N) which accepts the array A and N(size of array). 
Example 1:
Input:
5
3 6 4 8 9
Output: 27 24 26 22 21
Explanation: For the sum array S, at i=0 we
have 6+4+8+9. At i=1, 3+4+8+9. At i=2, we 
have 3+6+8+9. At i=3, we have 3+6+4+9. At
i = 4, we have 3+6+4+8. So S is 27 24 26 22 21.
Example 2:
Input:
6
4 5 7 3 10 1
Output: 26 25 23 27 20 29 
User Task:
Since this is a functional problem you did not have to worry about the input and output. You just have to complete the function SumArray() by storing arr[i]=S-arr[i]
Constraint :
1 <= T <= 10
1 <= N <= 10^{4}
1 <= A_{i} <= 10^{4}

Difficulty: EASY
Tags: Data structures

Mathematics
Skill types: Data structures

Starter code:
#User function Template for python3



# arr is the array

# n is the number of element in array

def SumArray(arr,n):

     # your code here

Solutions:
def SumArray(arr, n):
	l = []
	a = 0
	for i in arr:
		a += int(i)
	for i in range(n):
		arr[i] = a - int(arr[i])
	return arr


def SumArray(arr, n):
	total = 0
	for num in arr:
		total += int(num)
	for (i, num) in enumerate(arr):
		arr[i] = total - int(num)


def SumArray(arr, n):
	sum1 = 0
	for i in arr:
		sum1 += int(i)
	for i in range(n):
		arr[i] = sum1 - int(arr[i])
	return arr


def SumArray(arr, n):
	sum = 0
	for i in range(n):
		sum = sum + int(arr[i])
	for i in range(n):
		arr[i] = sum - int(arr[i])


def SumArray(arr, n):
	s = 0
	for i in arr:
		s += int(i)
	for i in range(n):
		diff = s - int(arr[i])
		arr[i] = diff
	return arr


def SumArray(arr, n):
	sumi = 0
	for i in arr:
		sumi = sumi + int(i)
	for i in range(len(arr)):
		arr[i] = sumi - int(arr[i])


def SumArray(arr, n):
	c = 0
	for i in arr:
		c += int(i)
	l = []
	for i in arr:
		l.append(c - int(i))
	arr[:] = l[:]
	return arr


def SumArray(arr, n):
	k = 0
	for i in arr:
		k += int(i)
	for i in range(n):
		arr[i] = k - int(arr[i])


def SumArray(arr, n):
	S = []
	for i in range(n):
		arr[i] = int(arr[i])
	k = sum(arr)
	for i in range(n - 1, -1, -1):
		arr[i] = k - arr[i]
	return arr


def SumArray(arr, n):
	Sum = 0
	for i in arr:
		Sum = Sum + int(i)
	for i in range(0, n):
		arr[i] = Sum - int(arr[i])
	return arr


def SumArray(arr, n):
	count = 0
	for i in arr:
		count += int(i)
	for i in range(n):
		arr[i] = count - int(arr[i])
	return arr


def SumArray(arr, n):
	total_sum = 0
	for i in range(n):
		total_sum += int(arr[i])
	for i in range(n):
		x = total_sum - int(arr[i])
		arr[i] = x


def SumArray(arr, n):
	sol = []
	total_sum = 0
	for i in range(n):
		total_sum += int(arr[i])
	for i in range(n):
		x = total_sum - int(arr[i])
		sol.insert(i, x)
	arr.clear()
	for i in range(n):
		arr.append(sol[i])


def SumArray(arr, n):
	sum_ = 0
	for i in range(n):
		sum_ += int(arr[i])
	for i in range(n):
		arr[i] = sum_ - int(arr[i])


def SumArray(arr, n):
	suma = 0
	for i in range(n):
		suma = suma + int(arr[i])
	for j in range(n):
		arr[j] = suma - int(arr[j])
	return arr


def SumArray(arr, n):
	c = []
	s = 0
	for i in arr:
		s += int(i)
	for i in range(n):
		d = s - int(arr[i])
		arr[i] = d
	return arr


def SumArray(arr, n):
	lsum = [0] * n
	rsum = [0] * n
	sum = [0] * n
	for i in range(1, n):
		lsum[i] = int(arr[i - 1]) + lsum[i - 1]
	for j in range(n - 2, -1, -1):
		rsum[j] = int(arr[j + 1]) + rsum[j + 1]
	for i in range(0, n):
		sum[i] = lsum[i] + rsum[i]
	return sum


def SumArray(arr, n):
	suma = 0
	for i in arr:
		suma += int(i)
	s = []
	for i in range(n):
		arr[i] = suma - int(arr[i])


def SumArray(arr, n):
	arr[:] = [int(x) for x in arr]
	s = sum(arr)
	arr[:] = [s - arr[index] for index in range(n)]


def SumArray(arr, n):
	for i in range(n):
		arr[i] = int(arr[i])
	S = sum(arr)
	for i in range(n):
		arr[i] = S - arr[i]


def SumArray(arr, n):
	for i in range(n):
		arr[i] = int(arr[i])
	s = sum(arr)
	for i in range(n):
		arr[i] = s - arr[i]


def SumArray(arr, n):
	p = [int(x) for x in arr]
	S = sum(p)
	for i in range(n):
		arr[i] = S - int(arr[i])


def SumArray(arr, n):
	x = arr
	x = list(map(int, arr))
	sums = sum(x)
	for i in range(n):
		arr[i] = sums - int(arr[i])


def SumArray(arr, n):
	s = []
	total = 0
	for number in arr:
		total += int(number)
	for i in range(n):
		arr[i] = total - int(arr[i])
	return arr


def SumArray(arr, n):
	sum_arr = 0
	for i in arr:
		sum_arr += int(i)
	for i in range(0, n):
		arr[i] = sum_arr - int(arr[i])


def SumArray(arr, n):
	ans = []
	for i in arr:
		ans.append(int(i))
	arr.clear()
	summ = sum(ans)
	for i in ans:
		arr.append(summ - i)


def SumArray(arr, n):
	sum_array = []
	total = 0
	for item in arr:
		total += int(item)
	for i in range(n):
		arr[i] = str(total - int(arr[i]))
	return sum_array


def SumArray(arr, n):
	total = sum(list(map(int, arr)))
	for i in range(n):
		arr[i] = total - int(arr[i])


def SumArray(arr, n):
	S = 0
	for i in range(0, n):
		S = S + int(arr[i])
	for i in range(0, n):
		arr[i] = S - int(arr[i])
	return arr


def SumArray(arr, n):
	lst = [int(i) for i in arr]
	s = sum(lst)
	for i in range(n):
		arr[i] = s - lst[i]
	return arr


def SumArray(arr, n):
	l = []
	x = 0
	for i in arr:
		x += int(i)
	for i in range(len(arr)):
		arr[i] = x - int(arr[i])
	return arr


def SumArray(arr, n):
	s = sum(map(int, arr))
	for x in range(n):
		arr[x] = s - int(arr[x])


def SumArray(arr, n):
	total = 0
	for num in range(n):
		total += int(arr[num])
	for digit in range(n):
		arr[digit] = total - int(arr[digit])


def SumArray(arr, n):
	li = []
	for i in arr:
		li.append(int(i))
	Sum = sum(li)
	arr.clear()
	for j in li:
		arr.append(Sum - j)


def SumArray(arr, n):
	sum = 0
	for i in range(n):
		sum = sum + int(arr[i])
	S = []
	for i in range(n):
		m = sum - int(arr[i])
		S.append(m)
	arr[:] = S[:]
	return arr


def SumArray(arr, n):
	sum = 0
	arr1 = []
	arr1[:] = arr[:]
	for i in range(len(arr)):
		sum += int(arr[i])
	for i in range(len(arr1)):
		arr.append(sum - int(arr1[i]))
		del arr[i - i]


def SumArray(arr, n):
	res = []
	total = 0
	for i in arr:
		total += int(i)
	for i in range(n):
		arr[i] = total - int(arr[i])


def SumArray(arr, n):
	total = 0
	for i in range(n):
		total += int(arr[i])
	for j in range(n):
		arr[j] = total - int(arr[j])


def SumArray(arr, n):
	s = 0
	for i in range(n):
		s = s + int(arr[i])
	for i in range(0, n):
		g = s - int(arr[i])
		arr[i] = g


def SumArray(arr, n):
	s = 0
	for i in range(0, n):
		s += int(arr[i])
	for i in range(0, n):
		x = s - int(arr[i])
		arr[i] = x


def SumArray(arr, n):
	for i in range(n):
		arr[i] = int(arr[i])
	a = sum(arr)
	for j in range(n):
		arr[j] = a - arr[j]
	return arr


import math

def SumArray(arr, n):
	s = 0
	for i in arr:
		s += int(i)
	for i in range(n):
		x = s - int(arr[i])
		arr[i] = x
	return arr


def SumArray(arr, n):
	s = 0
	d = []
	e = 0
	for x in arr:
		s = s + int(x)
	for y in range(n):
		arr[y] = s - int(arr[y])


def SumArray(arr, n):
	s = sum(map(int, arr))
	for i in range(n):
		diff = s - int(arr[i])
		arr[i] = diff
	return arr


def SumArray(arr, n):
	lis = [int(x) for x in arr]
	sum1 = sum(lis)
	res = []
	for x in lis:
		res.append(sum1 - x)
	for i in range(len(arr)):
		arr[i] = res[i]


def SumArray(arr, n):
	l = []
	for i in range(0, n):
		arr[i] = int(arr[i])
	s = sum(arr)
	for i in range(0, n):
		arr[i] = s - arr[i]
	return arr


def SumArray(arr, n):
	summa = sum(map(int, arr))
	for i in range(n):
		arr[i] = summa - int(arr[i])


def SumArray(arr, n):
	sum_all = 0
	for i in range(n):
		sum_all += int(arr[i])
	for i in range(n):
		arr[i] = sum_all - int(arr[i])


import numpy as np

def SumArray(arr, n):
	output = []
	s = 0
	for i in arr:
		s += int(i)
	for i in range(n):
		diff = s - int(arr[i])
		arr[i] = diff
	return arr


def SumArray(arr, n):
	s = []
	a = 0
	for i in range(n):
		a += int(arr[i])
		s.append(a)
	for i in range(n):
		arr[i] = s[n - 1] - int(arr[i])


def SumArray(arr, n):
	sum = 0
	for i in range(n):
		sum = sum + int(arr[i])
	op = []
	for i in range(n):
		diff = sum - int(arr[i])
		arr[i] = diff
	return arr


def SumArray(arr, n):
	temp = []
	for i in arr:
		temp.append(int(i))
	res = []
	ans = sum(temp)
	for i in range(n):
		res.append(ans - temp[i])
	for i in range(n):
		arr[i] = res[i]


def SumArray(arr, n):
	smallAns = 0
	for ele in arr:
		smallAns = smallAns + int(ele)
	finalAns = [0 for i in range(n)]
	for i in range(n):
		arr[i] = smallAns - int(arr[i])


def SumArray(arr, n):
	lst = []
	for i in range(n):
		lst.append(int(arr[i]))
	x = sum(lst)
	for i in range(n):
		arr[i] = x - lst[i]


def SumArray(arr, n):
	ss = [int(i) for i in arr]
	s = sum(ss)
	arr.clear()
	for i in ss:
		x = s - i
		arr.append(x)
	return arr