#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <stdio.h>
#include<iterator>
#include<memory.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
const int oo = 1e9 + 10;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
void solve() {
int n;
scanf("%d", &n);
ll ans = (39 * n * n - 75 * n + 48) % mod;
printf("%lld\n", ans);
}
int t = 1;
int main() {
//freopen("input.txt", " r", stdin);
//scanf("%d", &t);
while (t--) solve();
}
Copy