#include #include using namespace std; #define ll long long #define mod 1000000007 int main(){ ll N; cin >> N; cout << ((N*(N-1))%mod)*3 %mod << endl; return 0; }