N=int(input()) mod=10**9+7 def S1(x): # 1 2 4 5 7 8 10 11 13 14 ANS=(1+x)*x//2 t=x//3 return ANS-(1+t)*t//2*3 def S2(x): # 1 3 4 6 7 9 10 12 13 15 ANS=(1+x)*x//2 t=x//3 return ANS-(1+t)*t//2*3+t def S3(x): # 0 2 3 5 6 8 9 10 11 13 14 ANS=(1+x)*x//2 t=(x+1)//3 return ANS-(1+t)*t//2*3+t+t x=(N-2)//2 if N%3==0: print(S3(x)%mod) elif N%3==1: print(S1(x)%mod) else: print(S2(x)%mod)