k = int(input()) print(k + 1 + (2 * k + 1) * k + k + (2 * k - 1) * (k - 1))