You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
476 B

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9 + 7;
// 快速幂
int qmi(int a, int b) {
int res = 1;
while (b) {
if (b & 1) res = (LL)res * a % mod;
a = (LL)a * a % mod;
b >>= 1;
}
return res;
}
int main() {
LL n;
cin >> n;
LL a = (n * (n + 1)) % mod;
a = a * (2 * n + 1) % mod;
a = a * qmi(6, mod - 2) % mod;
cout << a << endl;
return 0;
}