解答
while 1: try: n = int(input()) area = 2 * n if n >= 3: area += ((n - 1) * (n - 2)) print(area) except: break