#!/bin/ruby def sumOfGroup(k) # Return the sum of the elements of the k'th group. p = k * (k - 1) / 2 p = 2 * p + 1 sum = 0 for i in 0..k-1 sum += p + 2 * i end return sum end k = gets.strip.to_i answer = sumOfGroup(k) puts answer