N = int(input()) maxim = 0 for i in range(1, N + 1): t = i + ((N - i) * (i + 1)) if t > maxim: maxim = t print(maxim % 1000007)