Given a series as shown below:
               1  2
            3  4  5  6
        7  8  9 10 11 12
 13 14 15 16 17 18 19 20
    ..........................
    ............................
             (so on)
Find the sum of Nth row.
 
Example 1:
Input: N = 2
Output: 18
Explanation: Sum of 2nd row is 3 + 4 + 
5 + 6 = 18.
Example 2:
Input: N = 4
Output: 132
Explanation: Sum of 4th row is 132.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function Nth_rowSum() which takes N as input parameter and returns sum of Nth row modulo 10^{9}  + 7.
 
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
	def Nth_rowSum(self, n):
		# Code here

Solutions:
class Solution:

	def Nth_rowSum(self, n):
		m = 10 ** 9 + 7
		return (2 * n * n + 1) * n % m


class Solution:

	def Nth_rowSum(self, n):
		prle = (n - 1) * n
		crle = n * (n + 1)
		return (crle * (crle + 1) // 2 - prle * (prle + 1) // 2) % (int(1000000000.0) + 7)


class Solution:

	def Nth_rowSum(self, n):
		if n == 1:
			return 3
		k1 = n * (n + 1)
		k2 = (n - 1) * n
		return (k1 * (k1 + 1) // 2 - k2 * (k2 + 1) // 2) % (10 ** 9 + 7)


class Solution:

	def Nth_rowSum(self, n):
		s = 0
		for i in range(n * (n - 1) + 1, n * (n + 1) + 1):
			s += i
		return s % 1000000007


class Solution:

	def Nth_rowSum(self, n):
		sum1 = 0
		for i in range((n - 1) * n + 1, n * (n - 1) + 1 + 2 * n):
			sum1 += i
		return sum1 % (10 ** 9 + 7)


class Solution:

	def Nth_rowSum(self, n):
		N = 10 ** 9 + 7
		ans = (2 * n * n + 1) * n
		return ans % N


class Solution:

	def Nth_rowSum(self, n):
		return (2 * n * n + 1) * n % 1000000007


class Solution:

	def Nth_rowSum(self, n):
		sum = 0
		start = n * (n - 1) + 1
		end = n * (n + 1)
		for i in range(start, end + 1):
			sum += i
		return sum % 1000000007


class Solution:

	def Nth_rowSum(self, n):
		return n * (2 * n * n + 1) % 1000000007
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		ob = Solution()
		ans = ob.Nth_rowSum(n)
		print(ans)


class Solution:

	def Nth_rowSum(self, n):
		m = 10 ** 9 + 7
		return (2 * n * n + 1) * n % m
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		ob = Solution()
		ans = ob.Nth_rowSum(n)
		print(ans)


class Solution:

	def Nth_rowSum(self, n):
		stv = n * (n - 1) + 1
		edv = n * (n + 1)
		sum = int((edv - stv + 1) * (stv + edv) / 2)
		return sum % 1000000007


class Solution:

	def Nth_rowSum(self, n):
		stv = n * (n - 1) + 1
		edv = n * (n + 1)
		sum = 0
		for i in range(stv, edv + 1):
			sum += i
		return sum % 1000000007


class Solution:

	def Nth_rowSum(self, n):
		start = 1 + (n - 1) * n
		end = n * (n + 1)
		sum = 0
		for i in range(start, end + 1):
			sum += i
		return sum % (10 ** 9 + 7)