I'm trying to calculate the number of reps from a rep height.

Example #1

Input: n = 2

Output: Result = 6

Because 1+2+2+1 = 6

--

Example #2

Input: n = 3

Output: Result = 12

Because 1+2+3+3+2+1 = 12

What formula could I use to get from input to output?