"""
Recommended Python Style Guide:
https://peps.python.org/pep-0008/#introduction
"""

import sys

n = int(input("Enter n: "))

if n < 0:
    print("Invalid input value!")
    sys.exit()

"""
Sum the first n positive odd numbers
"""
# Option a): while loop

# i is the counter in the while loop
i = 0
# Initialize the result sum to zero
sum = 0

while i < n:
    sum += 2 * i + 1
    i += 1
print(f"Sum of the first {n} odd numbers = {sum}")


# Option b): range() and for loop
# Initialize the result sum to zero
sum = 0

for i in range(1, 2*n, 2):
    sum += i

print(f"Sum of the first {n} odd numbers = {sum}")

"""
Sum the first n positive odd numbers,
while inverting the sign of every second number
"""

# Option a): while loop

# i is the counter in the while loop
i = 0
# Initialize the result sum to zero
sum_alternate = 0
sign = +1
while i < n:
    sum_alternate += sign*(2 * i + 1) 
    i += 1
    sign *= -1

print(
    f"Sum of the first {n} odd numbers with alternating signs = {sum_alternate}")

# Option b): range() and for loop
# Initialize the result sum to zero
sum_alternate = 0

sign = +1
for i in range(1, 2*n, 2):
    sum_alternate += sign*i
    sign *= -1

print(
    f"Sum of the first {n} odd numbers with alternating signs = {sum_alternate}")
