p = 10 ** 9 + 7 div3 = pow(3, p - 2, p) n = int(input()) ans = n * (n + 1) * div3 % p print(ans)