Given a number N, the task is to find the number of diagonals in N sided convex polygon.
Example 1:
Input: N = 5
Output: 5
Example 2:
Input: N = 6
Output: 9
Your Task:  
You don't need to read input or print anything. Your task is to complete the function diagonals() which takes N as input and returns the number of possible diagonals.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
3 ≤ N ≤ 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Geometry

Starter code: #User function Template for python3



class Solution:

    def diagonals(self, n):

        # code here 

Solutions:
class Solution:

	def diagonals(self, n):
		return int(n * (n - 3) // 2)


import math

class Solution:

	def diagonals(self, n):
		return int(n * (n - 3)) // 2


class Solution:

	def diagonals(self, n):
		c = n * (n - 3) // 2
		return c


class Solution:

	def diagonals(self, n):
		a = n * (n - 3) // 2
		return a


class Solution:

	def diagonals(self, n):
		k = n * (n - 3) // 2
		return k


class Solution:

	def diagonals(self, n):
		return abs(n * (n - 3) // 2)


class Solution:

	def diagonals(self, n):
		return n * (n - 1) // 2 - n


class Solution:

	def diagonals(self, n):
		dia = n * (n - 3) // 2
		return dia


class Solution:

	def diagonals(self, n):
		if n <= 3:
			return 0
		else:
			return n * (n - 3) // 2


from fractions import Fraction

class Solution:

	def diagonals(self, n):
		diag = Fraction(n * (n - 3))
		return Fraction(diag / 2)


class Solution:

	def diagonals(self, n):
		diagonal = n * (n - 3) // 2
		return diagonal


class Solution:

	def diagonals(self, n):
		ans = n * (n - 3) // 2
		return ans


class Solution:

	def diagonals(self, n):
		res = n * (n - 3) // 2
		return res


class Solution:

	def diagonals(self, n):
		num_of_diag = n * (n - 3) // 2
		return num_of_diag


class Solution:

	def diagonals(self, n):
		return n * (n - 3) // 2
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		print(ob.diagonals(n))


class Solution:

	def diagonals(self, n):
		x = n * (n - 3) // 2
		return x


class Solution:

	def diagonals(self, n):
		d = n * (n - 3) // 2
		return d


class Solution:

	def diagonals(self, n):
		for i in range(0, n + 1):
			return n * (n - 3) // 2


import math

class Solution:

	def diagonals(self, n):
		return math.floor(n * (n - 3) // 2)


import math

class Solution:

	def diagonals(self, n):
		return math.floor(n / 2) * (n - 3) if not n % 2 else math.floor(n / 2) * (n - 3) + math.floor((n - 3) / 2)