import sys import math def func(n, u): return u * (n - u + 1) + (n - u) n = int(input()) l = 0 r = n while r - l > 2: ml = (l * 2 + r) // 3 mr = (l + r * 2) // 3 if func(n, ml) > func(n, mr): r = mr else: l = ml print(max(func(n, l), func(n, l + 1), func(n, r)) % 1000007)