while True:
    try:
        i = int(input())
        s = i*(3*i+1)//2
        print(s)
    except:
        break