You are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair of triangles such that their intersection has non-zero area, and the total area of all triangles is equal to the area of the given polygon. The weight of a triangulation is the sum of weigths of triangles it consists of, where the weight of a triagle is denoted as the product of labels of its vertices.

Calculate the minimum weight among all triangulations of the polygon.


-----Input-----

The first line contains single integer $n$ ($3 \le n \le 500$) — the number of vertices in the regular polygon.


-----Output-----

Print one integer — the minimum weight among all triangulations of the given polygon.


-----Examples-----
Input
3

Output
6

Input
4

Output
18



-----Note-----

According to Wiki: polygon triangulation is the decomposition of a polygonal area (simple polygon) $P$ into a set of triangles, i. e., finding a set of triangles with pairwise non-intersecting interiors whose union is $P$.

In the first example the polygon is a triangle, so we don't need to cut it further, so the answer is $1 \cdot 2 \cdot 3 = 6$.

In the second example the polygon is a rectangle, so it should be divided into two triangles. It's optimal to cut it using diagonal $1-3$ so answer is $1 \cdot 2 \cdot 3 + 1 \cdot 3 \cdot 4 = 6 + 12 = 18$.

Difficulty: EASY
Tags: Dynamic programming

Mathematics

Greedy algorithms
Skill types: Dynamic programming

Greedy algorithms

Starter code:

Solutions:
n = int(input())
first = 2 * (n - 2)
second = 3 * ((n - 2) * (n - 1) // 2)
third = (n - 2) * (n - 1) * (2 * n - 3) // 6
print(first + second + third)


n = int(input())
ans = 0
f = 2
for i in range(3, n + 1):
	f *= i
	ans += f
	f //= i - 1
print(ans)


n = int(input())
print(n * (n - 1) * (n + 1) // 3 - 2)


n = int(input())
print((n ** 3 - n - 6) // 3)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


n = int(input())
sm = 0
for i in range(n - 2):
	sm += 1 * (2 + i) * (3 + i)
print(sm)


n = int(input().strip())
w = 6
c = 3
for _ in range(n - 3):
	w += c * (c + 1)
	c += 1
print(w)


n = int(input())
w = [0, 0, 6]
for i in range(4, n + 1):
	w.append(i * (i - 1))
print(sum(w))


N = int(input())
ans = 0
for i in range(N - 2):
	ans += (i + 2) * (i + 3)
print(ans)


n = int(input())
i = 2
s = 0
while i < n:
	s += i * (i + 1)
	i += 1
print(s)


v = int(input())
(ans, a, b) = (6, 3, 4)
while b <= v:
	ans += a * b
	a += 1
	b += 1
print(ans)


n = int(input())
s = []
for i in range(n + 1):
	s.append(i)
a = 0
for i in range(len(s)):
	if i == 0:
		continue
	else:
		if i + 2 >= len(s):
			break
		a += 1 * (i + 1) * (i + 2)
print(a)


n = int(input()) - 1
x = n * (n + 1) * (2 * n + 1)
x = x // 6
y = n * (n + 1)
y = y // 2
print(x + y - 2)


n = int(input())
ans = 6
for i in range(3, n):
	ans += i * (i + 1)
print(ans)


print(sum([i * (i - 1) for i in range(3, int(input()) + 1)]))


def triangulation(n):
	result = 0
	for i in range(2, n):
		result += i * (i + 1)
	return result
print(triangulation(int(input())))


n = int(input())
A = 2
T = 0
for i in range(0, n - 2):
	T = T + 1 * A * (A + 1)
	A += 1
print(T)


n = int(input())
print(n * (n - 1) * (2 * n - 1) // 6 + n * (n - 1) // 2 - 2)


import math
import array as arr
import bisect
inarr = lambda : map(int, input().split())
n = int(input())
sum1 = 0
i = 1
while i <= n - 2:
	sum1 += (i + 1) * (i + 2)
	i = i + 1
print(sum1)


from math import *
n = int(input())
if n > 3:
	print(sum((t * (t + 1) for t in range(2, n))))
else:
	print(6)


n = int(input())
dp = [[0] * (n + 1) for i in range(n + 1)]
for gap in range(3, n + 1):
	for l in range(1, n - gap + 2):
		r = l + gap - 1
		dp[l][r] = float('+inf')
		for k in range(l + 1, r):
			temp = l * r * k + dp[l][k] + dp[k][r]
			dp[l][r] = min(dp[l][r], temp)
print(dp[1][n])


n = int(input())
s = 0
for i in range(2, n, 1):
	s += i * (i + 1)
print(s)


n = int(input())
total = 0
for i in range(2, n):
	total += i * (i + 1)
print(total)


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
n = iread()
_sum = 0
for i in range(n - 2):
	_sum += (i + 2) * (i + 3)
print(_sum)


n = int(input())
sum = 0
while n != 2:
	sum += n * (n - 1)
	n = n - 1
print(int(sum))


n = int(input())
ans = 6
for i in range(n - 3):
	ans += (i + 3) * (i + 4)
print(ans)


n = int(input())
n -= 2
ans = sum([(i + 2) * (i + 1) for i in range(1, n + 1)])
print(ans)


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
ans = 0
for k in range(2, n):
	ans += k * (k + 1)
print(ans)


n = int(input())
p = 0
for k in range(2, n):
	p += k * (k + 1)
print(p)


a = int(input())
s = 0
for i in range(2, a):
	s += (i + 1) * i
print(s)


(n, res) = (int(input()), 0)
for i in range(2, n):
	res += i * (i + 1)
print(res)


n = int(input())
print(int(3 + n * (n - 1) / 2 + n * (n - 1) * (2 * n - 1) / 6 - 5))


n = int(input())
r = 0
tr = n
for i in range(2, n):
	r += i * (i + 1)
print(r)


n = int(input())
n -= 2
print((n ** 3 + 6 * n ** 2 + 11 * n) // 3)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		dp = [0] * 501
		dp[3] = 6
		for i in range(4, 501):
			dp[i] = dp[i - 1] + i * (i - 1)
		print(dp[inp()])
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
ans = 0
for i in range(2, n):
	temp = i * (i + 1)
	ans += temp
print(ans)


n = int(input())
p_min = 0
for i in range(n - 2):
	p_min += (2 + i) * (3 + i)
print(p_min)


def poly(n):
	sum = 0
	for i in range(2, n):
		sum += i * (i + 1)
	return sum
print(poly(int(input())))


n = int(input())
a = []
for i in range(2, n):
	a.append(i * (i + 1))
print(sum(a))


n = int(input())
res = 0

def getprod(n, pts):
	temp = pts[0] * pts[1] * pts[2]
	if n == 3:
		return temp
	else:
		del pts[1]
		return temp + getprod(n - 1, pts)
res = getprod(n, [i + 1 for i in range(n)])
print(res)


n = int(input())
counter = 0
for i in range(2, n):
	counter += i * (i + 1)
print(counter)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
p = 2 * 3
for i in range(3, n):
	p += i * (i + 1)
print(p)


n = int(input())
sum = int(0)
for i in range(2, n):
	sum += 1 * i * (i + 1)
print(sum)


def solve_it(n):
	tot = 0
	for i in range(2, n):
		tot += i * (i + 1)
	return tot
n = int(input())
print(solve_it(n))


n = int(input())
dp = [0, 0, 0, 6]
while len(dp) != n + 1:
	dp += [dp[-1] + len(dp) * (len(dp) - 1)]
print(dp[n])


def triangulate(n):
	if n <= 2:
		return 0
	return 1 * (n - 1) * n + triangulate(n - 1)
print(triangulate(int(input())))


N = int(input())
ans = 0
f = 2
s = 3
for i in range(N - 2):
	ans += 1 * f * s
	f = s
	s += 1
print(ans)


n = int(input())
i = 1
ans = 0
j = 2
while i != n - 1:
	ans += 1 * j * (j + 1)
	i += 1
	j += 1
print(ans)


inp = int(input())
weight = 0
for i in range(2, inp):
	weight += i * (i + 1)
print(weight)


from sys import stdin, stdout
import sys
import math
n = int(stdin.readline().strip())
min_sum = 0
for i in range(3, n + 1):
	min_sum += i * (i - 1)
print(min_sum)


n = int(input())
Ka = 0
Cnt = 0
for i in range(2, n):
	Cnt += i * (i + 1)
print(Cnt)


print(sum(((k + 2) * (k + 1) for k in range(1, int(input()) - 1))))


import sys

class DMinimumTriangulation:

	def solve(self):
		n = int(input())
		print(sum((k * (k + 1) for k in range(2, n))))
solver = DMinimumTriangulation()
input = sys.stdin.readline
solver.solve()


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
ans = 0
for i in range(3, n + 1):
	ans += i * (i - 1)
print(ans)


x = int(input())
ans = x * (x + 1) * (2 * x + 1) // 6 + x * (x + 1) // 2 - x * (x + 1) - 2
print(ans)


n = int(input())
n_t = n - 2
ans = 0
k = 2
for i in range(n_t):
	ans += 1 * k * (k + 1)
	k += 1
print(ans)


n = int(input())
store = 0
for i in range(2, n):
	store += i * (i + 1)
print(store)


def main():
	x = int(input())
	ans = 0
	for i in range(2, x):
		ans += i * (i + 1)
	print(ans)
main()


length = int(input())
s = 0
for i in range(2, length):
	j = i + 1
	s += i * j
print(s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	n = N()
	res = 0
	for i in range(2, n):
		res += i * (i + 1)
	print(res)
main()


N = int(input())
Ans = 0
for i in range(N, 2, -1):
	Ans += i * (i - 1)
print(Ans)


import os
import sys
import string
import math

def main(n):
	result = 0
	for i in range(2, n):
		result += i * (i + 1)
	return result

def parse():
	nums = int(input())
	return nums
print(main(parse()))


n = int(input())
c = 0
for i in range(2, n):
	c += (i + 1) * i
print(c)


n = int(input())
summ = 0
for i in range(n - 2):
	summ += (i + 2) * (i + 3)
print(summ)


arr = [0] * 501
arr[3] += 6
for i in range(4, 501):
	arr[i] += arr[i - 1] + i * (i - 1)
print(arr[int(input())])


print((lambda n: (n ** 3 - n) // 3 - 2)(int(input())))


def main():
	n = int(input())
	answer = 0
	for i in range(2, n):
		answer += i * (i + 1)
	print(answer)
main()


n = int(input())
answer = 0
for i in range(2, n):
	si = i * (i + 1)
	answer += si
print(answer)


n = int(input())
ans = ((n - 1) * n * (n + 1) - 6) / 3
print(int(ans))


vertices = int(input())
sumaprod = 0
for i in range(1, vertices - 1, 1):
	sumaprod = sumaprod + 1 * (i + 1) * (i + 2)
print(sumaprod)


print(sum((n * (n + 1) for n in range(2, int(input())))))


n = int(input())
su = 0
for i in range(2, n):
	su += i * (i + 1)
print(su)


from collections import defaultdict as dd
import math

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
n = nn()
total = 0
for i in range(n - 2):
	total = total + 1 * (i + 2) * (i + 3)
print(total)


from math import *
n = int(input())
tot = 0
curr = 2
while curr != n:
	tot += curr * (curr + 1)
	curr += 1
print(tot)


n = int(input(''))
if n % 3 == 0:
	a = n // 3
	print(a * (n + 1) * (n - 1) - 2)
elif n % 3 == 1:
	a = (n - 1) // 3
	print(n * a * (n + 1) - 2)
elif n % 3 == 2:
	a = (n + 1) // 3
	print(n * a * (n - 1) - 2)


n = int(input())
ans = [0, 0, 0, 6]
for i in range(4, n + 1):
	ans.append(ans[-1] + i * (i - 1))
print(ans[n])


n = int(input())
pro = 0
while n != 2:
	pro += 1 * n * (n - 1)
	n -= 1
print(pro)


import sys

def main():
	n = int(sys.stdin.readline().strip())
	sum = 0
	for i in range(2, n):
		sum += i * (i + 1)
	print(sum)
main()


n = int(input())
co = 0
for i in range(3, n + 1):
	co += i * (i - 1)
print(co)


def min_weight_triangulation(n):
	min_weight = 0
	for i in range(2, n):
		min_weight += i * (i + 1)
	return min_weight
n = int(input())
print(min_weight_triangulation(n))


print(sum((i * (i + 1) for i in range(2, int(input())))))


n = int(input())
a = list(range(1, n + 1))
ans = 0
i = 1
while i + 1 < n:
	ans += a[i] * a[i + 1]
	i += 1
print(ans)


n = int(input())
count = 0
for i in range(2, n):
	count += i * (i + 1)
print(count)


n = int(input())
t = 0
for i in range(2, n):
	t += i * (i + 1)
print(t)


n = int(input())
j = 1
k = 3
sum = 0
for i in range(1, n - 1):
	sum = sum + j * (k - 1) * k
	k = k + 1
print(sum)


def main():
	n = int(input())
	ans = 0
	for i in range(2, n):
		ans += i * (i + 1)
	print(ans)
	return 0
exit(main())


n = int(input())
p = 0
for i in range(2, n):
	p = p + i * (i + 1)
print(p)


Q = int(input())
s = 0
for i in range(3, Q + 1):
	s += (i - 1) * i
print(s)


n = int(input())
cnt = 0
for i in range(3, n + 1):
	cnt += i * (i - 1)
print(cnt)


n = int(input())
summ = 0
for i in range(3, n + 1):
	summ += 1 * (i - 1) * i
print(summ)


L = [0] * 501
for i in range(3, 501):
	L[i] += L[i - 1]
	L[i] += i * (i - 1)
print(L[int(input())])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	r = 0
	for i in range(n - 2):
		r += (i + 2) * (i + 3)
	return r
print(main())


s = 0
for i in range(int(input()) - 2):
	s += (i + 2) * (i + 3)
print(s)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())
n = int(input())
print((n ** 3 - n) // 3 - 2)


vert = int(input())
minWeight = 0
for i in range(2, vert):
	minWeight += i * (i + 1)
print(minWeight)


A = []
for i in range(550):
	x = 0
	for j in range(2, i - 1):
		x += j * (j + 1)
	A.append(x)
print(A[int(input()) + 1])
exit()

def quickpower(x, power):
	ans = 1
	while power != 0:
		if power & 1 == 1:
			ans *= x
		x = x ** 2
		power = power // 2
	return ans
print(quickpower(-7, 2))
(n, k) = map(int, input().split())
A = list(map(int, input().split()))


ans = 0
for i in range(2, int(input())):
	ans += i * (i + 1)
print(ans)


n = int(input())
if n >= 3 and n <= 500:
	print((n * n * n - n) // 3 - 2)


ans = 0
for t in range(2, int(input())):
	ans += t * (t + 1)
print(ans)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	n = int(input())
	ans = 0
	for i in range(2, n):
		ans += i * (i + 1)
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


t = int(input())
cou = 6
i = 3
while i < t:
	cou += i * (i + 1)
	i += 1
print(cou)


import sys
input = sys.stdin.readline
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


def solve(n):
	res = 0
	for i in range(2, n):
		res += i * (i + 1)
	return res
t = 1
for _ in range(t):
	n = int(input())
	res = solve(n)
	print(res)


n = int(input())
s = 0
i1 = 2
i2 = 3
for i in range(n - 2):
	s += 1 * i1 * i2
	i1 += 1
	i2 += 1
print(s)


import sys
from collections import defaultdict
import heapq
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


N = int(input())
total = 0
for n in range(2, N):
	total += n * (n + 1)
print(total)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
import heapq
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
ans = 0
for i in range(2, n):
	ans = ans + i * (i + 1)
print(ans)


class Triangulation(object):

	def __init__(self):
		pass

	def best_bu(self, n):
		tb = [[0 for _ in range(0, n + 1)] for _ in range(0, n + 1)]
		for i in range(1, n + 1):
			for j in range(i + 2, n + 1):
				tb[i][j] = 1 << 31
		for i in range(1, n + 1):
			for j in range(i + 2, n + 1):
				for k in range(i + 1, j):
					tb[i][j] = min(tb[i][j], i * k * j + tb[i][k] + tb[k][j])
		return tb[1][n]

def main():
	n = int(input())
	tr = Triangulation()
	print(tr.best_bu(n))
	return 0
main()


n = int(input())
a = 2
b = 3
sum = 0
while b <= n:
	sum += a * b
	a = b
	b = b + 1
print(sum)


n = int(input())
s = 0
for i in range(3, n + 1):
	s += i * (i - 1)
print(s)


n = eval(input())
c = 0
for j in range(2, n):
	c += j * (j + 1)
print(c)


n = int(input())
dp = [6, 18]
if n == 3:
	print(6)
elif n == 4:
	print(18)
else:
	for i in range(5, n + 1):
		dp.append(dp[-1] + i * (i - 1))
	print(dp[-1])


import sys
input = sys.stdin.readline
n = int(input())
print(sum((i * (i + 1) for i in range(2, n))))


n = int(input())
mult = 0
for x in range(2, n):
	curr = x * (x + 1)
	mult += curr
print(mult)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
print((n - 1) * n * (n + 1) // 3 - 2)


n = int(input()) + 1
p = 0
for i in range(3, n):
	p += i * (i - 1)
print(p)


n = int(input())
f = 6
for i in range(4, n + 1):
	f += (i - 1) * i
print(f)


from functools import reduce
from operator import mul
from fractions import Fraction

def nCk(n, k):
	return int(reduce(mul, (Fraction(n - i, i + 1) for i in range(k)), 1))
n = int(input())
print(6 * nCk(n - 3, 0) + 12 * nCk(n - 3, 1) + 8 * nCk(n - 3, 2) + 2 * nCk(n - 3, 3))


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
s = 0
n = I()
for i in range(2, n):
	s += i * (i + 1)
print(s)


t = int(input())
c = 0
for i in range(2, t):
	c += i * (i + 1)
print(c)


n = int(input())
out = 0
for i in range(2, n):
	out += i * (i + 1)
print(out)


def main():
	n = int(input())
	dp = [[float('inf')] * (n + 1) for _ in range(n + 1)]
	for i in range(n, 0, -1):
		for j in range(i + 1, n + 1):
			if j - i == 1:
				dp[i][j] = 0
			elif j - i == 2:
				dp[i][j] = i * (i + 1) * (i + 2)
			else:
				for k in range(i + 1, j):
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + i * j * k)
	print(dp[1][n])
main()


n = int(input())
ans = (n ** 3 - n) // 3 - 2
print(ans)


digl = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
mod = 10 ** 9 + 7
n = ii()
sm = 0
l = list(range(2, n + 1))
for (i, j) in zip(l, l[1:]):
	sm += i * j
print(sm)


n = int(input())
ans = 0
t1 = 2
t2 = 3
for i in range(n - 2):
	ans = ans + t1 * t2
	t1 = t1 + 1
	t2 = t2 + 1
print(ans)


n = eval(input())
count = 0
for i in range(2, n):
	count += i * (i + 1)
print(count)


from sys import stdin, stdout
input = int(stdin.readline())
i = 1
ans = 0
while i <= input - 2:
	ans += 1 * (i + 1) * (i + 2)
	i += 1
stdout.write(str(ans))


import sys
S = sys.stdin.read()
S = int(S)

def f(S):
	if S == 3:
		return 6
	return S * (S - 1) + f(S - 1)
print(f(S))


n = int(input())
num = 0
for i in range(3, n + 1):
	num += i * (i - 1)
print(num)


m = int(input())
result = 0
for i in range(2, m):
	result += i * (i + 1)
print(result)


n = int(input())
w = 0
for i in range(1, n - 1):
	w += (i + 1) * (i + 2)
print(w)


n = int(input())
if n == 3:
	print(6)
	exit()
sm = 0
for i in range(2, n):
	sm += i * (i + 1)
print(sm)


n = int(input())
a = n * (n + 1) * (2 * n + 1) // 6
b = n * (n + 1) // 2
print(a - b - 2)


import sys
n = int(sys.stdin.readline())
value = 0
for i in range(2, n):
	value += i * (i + 1)
print(value)


ves = 0
for i in range(2, int(input())):
	ves += i * (i + 1)
print(ves)


n = int(input())
suma = 0
while n >= 3:
	suma += n * (n - 1)
	n -= 1
print(suma)


import sys
from math import *
from fractions import gcd
readints = lambda : map(int, input().strip('\n').split())
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


n = int(input())
(x, y) = (2, 3)
t = 0
for i in range(n - 2):
	t += x * y
	x += 1
	y += 1
print(t)


n = int(input())
mas = []
mas.append(6)
mas.append(12)
for i in range(n - 3):
	mas.append(mas[-1] + mas[-1] - mas[-2] + 2)
mas.remove(mas[-1])
print(sum(mas))


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
ans = 0
x = 2
for i in range(n - 2):
	ans += x * (x + 1)
	x += 1
print(ans)


import sys
imput = sys.stdin.buffer.readline
n = int(input())
b = 2
c = 3
ans = 0
while c <= n:
	ans += b * c
	b += 1
	c += 1
print(ans)


n = int(input())
if n < 2:
	print('0')
else:
	a = 1
	b = 3
	area = 0
	for i in range(2, n):
		area += i * (i + 1)
	print(area)


n = int(input())
res = 0
for x in range(2, n):
	res += x * (x + 1)
print(res)


import time
n = int(input())
start = time.time()
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)
finish = time.time()


n = int(input())
i = 2
j = 3
sum = 0
while j <= n:
	sum += i * j
	i += 1
	j += 1
print(sum)


n = int(input())
dp = [0] * (n + 1)
dp[3] = 6
for i in range(4, n + 1):
	dp[i] = dp[i - 1] + i * (i - 1)
print(dp[n])


n = int(input())
sum_ = 0
for i in range(2, n):
	sum_ += i * (i + 1)
print(sum_)


from collections import defaultdict
from sys import stdin, stdout
import bisect
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


n = int(input())
c = 0
for i in range(n - 2):
	c += (i + 2) * (i + 3)
print(c)


n = int(input())
dp = []
dp.append(0)
dp.append(0)
dp.append(0)
dp.append(6)
for i in range(4, 501):
	dp.append(dp[i - 1] + i * (i - 1))
print(dp[n])


n = int(input())
a = 2
b = 3
ans = 0
for i in range(0, n - 2):
	ans += a * b
	a += 1
	b += 1
print(ans)


n = int(input())
sum = 0
if n < 3:
	print(0)
else:
	for i in range(3, n + 1):
		sum += 1 * (i - 1) * i
	print(sum)


n = int(input())
i = 2
ac = 0
while i <= n - 1:
	ac += i * (i + 1)
	i += 1
print(ac)


n = int(input())
total = 0
j = 2
for j in range(2, n):
	total += j * (j + 1)
print(total)


n = int(input())
ans = sum([(x - 1) * x for x in range(3, n + 1)])
print(ans)


n = int(input())

def mintri(n):
	if n == 3:
		return 6
	else:
		return n * (n - 1) + mintri(n - 1)
n = mintri(n)
print(n)


import sys
n = int(input())
summe = 0
for i in range(2, n):
	summe += i * (i + 1)
print(summe)


n = int(input())
sm = 0
i = 2
while i < n:
	sm = sm + i * (i + 1)
	i = i + 1
print(sm)


n = int(input())
res = 6
for i in range(3, n):
	res += i * (i + 1)
print(res)


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
ans = 0
for (i, j) in zip(range(2, N + 1), range(3, N + 1)):
	ans += i * j
print(ans)


n = int(input())
(t, l) = (2, 0)
while t < n:
	l += t * (t + 1)
	t = t + 1
print(l)


i = int(input())
print((i - 1) * i * (i + 1) // 3 - 2)


n = int(input())
summary = 0
for i in range(3, n + 1):
	summary += i * (i - 1)
print(summary)


N = int(input())
res = 0
for i in range(2, N):
	res += i * (i + 1)
print(res)


from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	n = int(input())
	ans = 0
	x = 2
	while x < n:
		ans += x * (x + 1)
		x += 1
	print(ans)
sync_with_stdio(False)
main()


n = int(input())
min_weight = 0
for i in range(2, n):
	min_weight += i * (i + 1)
print(min_weight)


from math import *
n = int(input())
a = floor(n ** 3 - n - 6) / 3
b = int(a)
print(b)


n = int(input())
t = 0
print(n * (n + 1) * (2 * n + 1) // 6 - n * (n + 1) // 2 - 2)


def main():
	n = int(input())
	print(n * (n + 1) * (n - 1) // 3 - 2)
main()


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
mod = 10 ** 9 + 7

def modu(a, m):
	if a % m:
		return a % m
	return m

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s
ans = 0
for i in range(2, int(input())):
	ans += i * (i + 1)
print(ans)


import math
print(sum([i * (i + 1) for i in range(2, int(input()))]))


N = int(input())
pv = 2
nv = 3
sums = 0
for i in range(N - 2):
	sums += pv * nv
	pv += 1
	nv += 1
print(sums)


import sys
n = int(sys.stdin.readline().strip())
w = 0
for i in range(2, n):
	w += i * (i + 1)
print(w)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
n = int(input())
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = 0
for i in range(2, n):
	s += i * (i + 1)
print(s)


n = int(input())
m = 0
for i in range(2, n):
	m += i * (i + 1)
print(m)


n = eval(input())
ans = 0
for i in range(n - 2):
	ans += (i + 2) * (i + 3)
print(ans)


def nCk(n, k):
	if n < k:
		return 0
	if k == 0:
		return 1
	if k == 1:
		return n if n != 0 else 0
	x = n
	for i in range(1, k):
		x *= n - i
	y = 1
	while k > 0:
		y *= k
		k -= 1
	x //= y
	return x
n = int(input())
print(6 * nCk(n - 3, 0) + 12 * nCk(n - 3, 1) + 8 * nCk(n - 3, 2) + 2 * nCk(n - 3, 3))


x = int(input())
m = 0
for i in range(3, x + 1):
	m += i * (i - 1)
print(m)


n = int(input())

def func(n):
	if n == 3:
		return 6
	return n * (n - 1) + func(n - 1)
print(func(n))


s = 0
n = int(input())
if n == 3:
	print('6')
else:
	while n != 4:
		s += n * (n - 1)
		n -= 1
	s += 18
	print(s)


def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())
mm = 1000000007

def solve():
	t = 1
	for it in range(t):
		n = nu()
		cc = 0
		for i in range(2, n):
			cc += i * (i + 1)
		print(cc)

def __starting_point():
	solve()
__starting_point()


n = int(input())
res = 0
last = 2
for i in range(n - 2):
	res += last * (i + 3)
	last = i + 3
print(res)


def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
n = ri()
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)


import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
n = [int(val) for val in sys.stdin.readline().split()][0]
summ = 0
for i in range(n - 2):
	summ += 1 * (i + 2) * (i + 3)
print(summ)


n = int(input())
a = [0] * 501
a[3] = 6
a[4] = 18
lastKnown = [1, 3, 4]
if a[n] != 0:
	print(a[n])
else:
	for i in range(5, n + 1):
		currLast = [lastKnown[0], lastKnown[1] + 1, lastKnown[2] + 1]
		currNum = lastKnown[0] * (lastKnown[1] + 1) * (lastKnown[2] + 1)
		a[i] = a[i - 1] + currNum
		lastKnown = currLast
	print(a[n])


n = int(input())
summ = 0
for i in range(2, n):
	summ += i * (i + 1)
print(summ)


n = int(input())
f = 0
for g in range(3, n + 1):
	f += (g - 1) * g
print(f)


import sys
from heapq import heappush, heappop

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		print((n - 1) * n * (2 * n - 1) // 6 + (n - 1) * n // 2 - 2)
Main().solve()


n = int(input())
a = 0
for i in range(2, n):
	a += i * (i + 1)
print(a)


num = int(input())
dp = [0] * 501
dp[2] = 6
for i in range(3, num + 1):
	dp[i] = dp[i - 1] + (i + 1) * i
print(dp[num - 1])


n = int(input())
res = 0
for k in range(2, n):
	res += k * (k + 1)
print(res)


n = int(input())
ans = 6
i = 3
while i < n:
	ans += i * (i + 1)
	i += 1
print(ans)


import sys
num_vertices = int(sys.stdin.readline())
solution = 0
for vertex in range(num_vertices, 2, -1):
	solution += vertex * (vertex - 1)
print(solution)


from collections import defaultdict
from functools import reduce
mi = lambda : [int(i) for i in input().split()]
flat = lambda l: reduce(lambda a, b: a + b, l)
n = mi()[0]
if n == 3:
	print(6)
elif n == 4:
	print(18)
else:
	r = 0
	for i in range(2, n):
		r += (i + 1) * i
	print(r)


n = int(input())
j = n
s = 0
while j > 2:
	s += j * (j - 1)
	j -= 1
print(s)


TN = 1

def solution():
	n = int(input())
	ans = [0, 0, 0, 6, 18] + [0 for i in range(n)]
	for i in range(5, n + 1):
		ans[i] = ans[i - 1] + i * (i - 1)
	print(ans[n])
while TN != 0:
	solution()
	TN -= 1


N = int(input())
w_sum = 0
for i in range(1, N - 1):
	w_sum += 1 * (i + 1) * (i + 2)
print(w_sum)


n = int(input())
i = [1, 2, 3]
v = 3
ans = 0
while v < n + 1:
	p = 1
	for j in range(3):
		p = p * i[j]
	ans += p
	v = i[2] + 1
	i = [1, i[2], i[2] + 1]
print(ans)


n = int(input())
pr = 0
for i in range(n - 2):
	pr += (i + 2) * (i + 3)
print(pr)


n = int(input())
if n == 4:
	print(18)
	exit()
if n == 3:
	print(6)
	exit()
total = sum((x * (x + 1) for x in range(2, n)))
print(total)


n = int(input())
an = 6
ind = 3
while ind < n:
	an += ind * (ind + 1)
	ind += 1
print(an)


import sys
input = sys.stdin.readline
prnt = sys.stdout.write
n = int(input())
res = 0
for i in range(2, n):
	res += i * (i + 1)
print(res)


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
dp = [0, 0, 0]
for i in range(3, n + 1):
	dp.append(dp[i - 1] + i * (i - 1))
print(dp[n])


a = int(input())
ans = 0
for i in range(a - 2):
	ans += (i + 2) * (i + 3)
print(ans)


n = int(input())
(x, y, z) = (1, 2, 3)
s = x * y * z
while z != n:
	y = z
	z = z + 1
	s = s + x * y * z
print(s)


n = int(input())
weight = 0
for i in range(3, n + 1):
	weight += i * (i - 1)
print(weight)


x = int(input())
x -= 1
a = x * (x + 1) * (2 * x + 1) // 6
b = x * (x + 1) // 2
print(a + b - 2)


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
ans = n * (n * n - 1) // 3 - 2
print(ans)


def fun(n):
	ans = n * (n + 1) * (n - 1)
	print(ans // 3 - 2)
n = int(input())
fun(n)


def main():
	sum = 0
	angles = int(input())
	for i in range(3, angles + 1):
		sum += i * (i - 1)
	print(sum)
main()


n = int(input())
p = 2
ans = 0
while p != n:
	ans += p * (p + 1)
	p += 1
print(ans)


n = int(input())
res = 0
for i in range(3, n + 1):
	res += i * (i - 1)
print(res)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
n = RI()
print((n * (n - 1) * (n + 1) - 6) // 3)


n = int(input())
t = 0
for i in range(n - 2):
	t += (i + 2) * (i + 3)
print(t)


def triangulaton(n):
	s = 0
	for i in range(2, n):
		s += i * (i + 1)
	return s
n = int(input())
print(triangulaton(n))


n = int(input())
sum1 = 0
for i in range(2, n):
	sum1 += i * (i + 1)
print(sum1)


n = int(input())
a = 1
b = 2
c = 3
s = a * b * c
while c != n:
	b = b + 1
	c = c + 1
	s = s + a * b * c
print(s)


def Solve(n):
	if n < 3:
		print(0)
		return
	table = [[0 for i in range(n)] for j in range(n)]
	for gap in range(n):
		i = 0
		for j in range(gap, n):
			if j < i + 2:
				table[i][j] = 0
			else:
				table[i][j] = float('inf')
				for k in range(i + 1, j):
					val = table[i][k] + table[k][j] + (i + 1) * (j + 1) * (k + 1)
					if table[i][j] > val:
						table[i][j] = val
			i += 1
	print(table[0][n - 1])

def main():
	n = int(input())
	Solve(n)
main()


n = int(input())
s = 0
for x in range(2, n):
	s += x * (x + 1)
print(s)


N = int(input())
A = [0, 0, 0]
for i in range(3, N + 1):
	A.append(A[i - 1] + 1 * (i - 1) * i)
print(A[-1])


from sys import stdin
inp = lambda : stdin.readline().strip()
n = int(inp())
dp = [6]
c = 3
for i in range(n - 3):
	dp.append(dp[len(dp) - 1] + c * (c + 1))
	c += 1
print(dp[len(dp) - 1])


import sys
printn = lambda x: sys.stdout.write(x)
DBG = True

def ddprint(x):
	if DBG:
		print(x)
n = int(input())
sum = 0
for i in range(2, n):
	sum += i * (i + 1)
print(sum)


n = int(input())
x = 0
for i in range(3, n + 1):
	x += i * (i - 1)
print(x)


n = int(input())
sumer = 0
for i in range(2, n):
	sumer += i * (i + 1)
print(sumer)


import heapq
import sys
input = sys.stdin.readline
n = int(input())
ANS = 0
for i in range(3, n + 1):
	ANS += i * (i - 1)
print(ANS)


a = int(input())
l = 0
for x in range(2, a):
	l += x * (x + 1)
print(l)


import math
import sys
import bisect
input = sys.stdin.readline
t = 1
for _ in range(t):
	n = int(input())
	suma = 0
	for i in range(2, n):
		suma += i * (i + 1)
	print(suma)


n = int(input())
ans = 6
li = [1, 3] + [i for i in range(4, n + 1)]
le = len(li)
for i in range(1, le - 1):
	ans += li[i] * li[i + 1]
print(ans)


n = int(input())
weight = 0
for i in range(2, n):
	weight += i * (i + 1)
print(weight)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	ans = 0
	for i in range(3, n + 1):
		ans += i * (i - 1)
	print(ans)
testcase(1)


n = int(input())
weight = 0
for x in range(n - 2):
	weight += 1 * (x + 2) * (x + 3)
print(weight)


t = int(input())
sum = 0
for i in range(2, t):
	sum += i * (i + 1)
print(sum)


n = int(input())
res = 0
for x in range(3, n + 1):
	res += 1 * (x - 1) * x
print(res)


N = int(input())
print(sum([(b + 1) * (b + 2) for b in range(1, N - 1)]))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
ans = 0
for i in range(2, n):
	ans += i * (i + 1)
print(ans)