MOD = 10**9+7 N = int(input()) if N==1: print(12) elif N==2: print(65) else: print(((3*N*2+1)**2//2+1-N**2)%MOD)