while True:
    try:
        n=int(input())
        an=(n-1)*3+2
        sum=n*(2+an)/2
        print(int(sum))
    except:
        break