Your are given N students with some goodies to be distrubuted among them such that student at i^{th} index gets exactly i amount of goodies (considering no wastage). The goodies has already been distributed by some other. Your task is to check if it can be redistributed such that student at i^{th} index gets i amount of goodies. 
 
Example 1:
Input:
N = 5
Arr = {7, 4, 1, 1, 2}
Output:
YES
Explanation:
Since, all the goods can be
redistributed as 1 2 3 4 5 
(i^{th} students get i number of 
goodies).So, output is YES.
 
Example 2:
Input:
N = 5
Arr = {1, 1, 1, 1, 1}
Output:
NO
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function leftIndex() which takes the array Arr[] and its size N as inputs and returns  true if we can redistribute in the requried way, otherwise false .
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 10^{7}
0 <= A_{i} <= 10^{18}

Difficulty: EASY
Tags: Data structures

Mathematics
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def possible(self, arr, n):

        #code here.

    

    





Solutions:
class Solution:

	def possible(self, arr, n):
		total = 0
		for i in range(n):
			total += i + 1
		return True if total == sum(arr) else False


class Solution:

	def possible(self, arr, n):
		s = n * (n + 1) // 2
		if sum(arr) == s:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		a = sum(arr)
		b = n * (n + 1) // 2
		if a == b:
			return 1
		else:
			return 0


class Solution:

	def possible(self, arr, n):
		s = n * (n + 1) // 2
		s1 = 0
		for i in range(n):
			s1 += arr[i]
		if s1 == s:
			return 1
		return 0


class Solution:

	def possible(self, arr, n):
		return sum(arr) == n * (n + 1) // 2


class Solution:

	def possible(self, arr, n):
		s = n * (n + 1) // 2
		if sum(arr) == s:
			return 1
		else:
			return 0


class Solution:

	def possible(self, arr, n):
		if sum(arr) == sum(list(range(1, n + 1))):
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		total = int(n * (n + 1) / 2)
		arrSum = sum(arr)
		if arrSum == total:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		total = 0
		for item in arr:
			total += item
		if total == int(n * (n + 1) / 2):
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		sum = 0
		sum1 = 0
		for i in arr:
			sum = sum + i
		for i in range(1, n + 1):
			sum1 = sum1 + i
		if sum == sum1:
			return 1
		return 0


class Solution:

	def possible(self, arr, n):
		k = int(n * (n + 1) / 2)
		if sum(arr) == k:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		a = sum(arr)
		b = n * (n + 1) // 2
		if a == b:
			return True
		return False


class Solution:

	def possible(self, arr, n):
		x = sum(arr)
		y = n * (n + 1) // 2
		if x == y:
			return True
		return False


class Solution:

	def possible(self, arr, n):
		s = 0
		for i in arr:
			s += i
		x = 0
		for i in range(1, n + 1):
			x += i
		if s == x:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		sm = sum(arr)
		sm1 = n * (n + 1) / 2
		return sm == sm1


class Solution:

	def possible(self, arr: list, n: int) -> bool:
		target_sum = n * (n + 1) // 2
		actual_sum = 0
		for i in range(n):
			actual_sum += arr[i]
		return actual_sum == target_sum


class Solution:

	def possible(self, arr, n):
		total = n * (n + 1) // 2
		sum1 = sum(arr)
		if total == sum1:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		tot = int(n * (n + 1) / 2)
		summ = sum(arr)
		if tot == summ:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		a = n * (n + 1)
		a1 = a // 2
		if sum(arr) == a1:
			return True
		else:
			return False


class Solution:

	def possible(self, arr, n):
		res = n * (n + 1) // 2
		if res == sum(arr):
			return True
		return False


class Solution:

	def possible(self, a, n):
		s1 = sum(a)
		b = [i for i in range(1, n + 1)]
		s2 = sum(b)
		if s1 == s2:
			return True
		return False

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		a = [int(x) for x in input().strip().split()]
		ob = Solution()
		if ob.possible(a, n) == True:
			print('YES')
		else:
			print('NO')
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def possible(self, arr, n):
		k = n * (n + 1) // 2
		y = sum(arr)
		if k == y:
			return 1
		return 0

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		a = [int(x) for x in input().strip().split()]
		ob = Solution()
		if ob.possible(a, n) == True:
			print('YES')
		else:
			print('NO')
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def possible(self, arr, n):
		sum = 0
		index_sum = int(n * (n + 1) / 2)
		for i in range(0, n):
			sum += arr[i]
		if sum == index_sum:
			return True
		else:
			return False

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		a = [int(x) for x in input().strip().split()]
		ob = Solution()
		if ob.possible(a, n) == True:
			print('YES')
		else:
			print('NO')
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def possible(self, arr, n):
		su = 0
		for i in arr:
			su += i
		return su == n * (n + 1) // 2


class Solution:

	def possible(self, arr, n):
		sumx = sum(arr)
		cal = n * (n + 1) // 2
		return sumx == cal


class Solution:

	def possible(self, arr, n):
		sum = 0
		for i in range(n):
			sum += arr[i]
		q = n * (n + 1) // 2
		if sum == q:
			return True
		return False


class Solution:

	def possible(self, arr, n):
		s = 0
		for i in arr:
			s += i
		return 1 if s == int(n * (n + 1) * 0.5) else 0


class Solution:

	def possible(self, arr, n):
		y = sum(arr)
		x = n * (n + 1) // 2
		if y == x:
			return 1
		else:
			return 0


class Solution:

	def possible(self, arr, n):
		totalSum = 0
		expectedSum = 0
		for (i, v) in enumerate(arr):
			totalSum += v
			expectedSum += i + 1
		return totalSum == expectedSum