pub mod mod_int { use std::{fmt, ops}; #[derive(Clone, Copy, Debug)] pub struct ModInt(u64); impl ModInt { const MOD: u64 = 1_000_000_007; pub fn new(mut x: u64) -> Self { if x >= Self::MOD { x %= Self::MOD; } Self(x) } pub fn zero() -> Self { Self(0) } pub fn one() -> Self { Self(1) } } impl From for ModInt { fn from(x: usize) -> Self { Self::new(x as u64) } } impl From for ModInt { fn from(mut x: i64) -> Self { let m = Self::MOD as i64; if x.abs() >= m { x %= m; } if x < 0 { x += m } Self::new(x as u64) } } impl ops::Add for ModInt { type Output = Self; fn add(self, other: Self) -> Self { let mut x = self.0 + other.0; if x >= Self::MOD { x -= Self::MOD; } Self(x) } } impl ops::AddAssign for ModInt { fn add_assign(&mut self, other: Self) { *self = *self + other; } } impl ops::Sub for ModInt { type Output = Self; fn sub(mut self, other: Self) -> Self { if self.0 < other.0 { self.0 += Self::MOD; } Self(self.0 - other.0) } } impl ops::SubAssign for ModInt { fn sub_assign(&mut self, other: Self) { *self = *self - other; } } impl ops::Mul for ModInt { type Output = Self; fn mul(self, other: Self) -> Self { Self::new(self.0 * other.0) } } impl ops::MulAssign for ModInt { fn mul_assign(&mut self, other: Self) { *self = *self * other; } } impl fmt::Display for ModInt { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } impl ModInt { pub fn pow(mut self, mut n: u64) -> Self { let mut res = Self::one(); while n > 0 { if n & 1 == 1 { res *= self; } self *= self; n >>= 1; } res } pub fn inv(self) -> Self { self.pow(Self::MOD - 2) } } } use mod_int::ModInt; fn main() { let ref mut buf = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), buf).ok(); let mut iter = buf.split_whitespace(); macro_rules! scan { ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::>()); (($($t:tt),*)) => (($(scan!($t)),*)); (Usize1) => (scan!(usize) - 1); (Bytes) => (scan!(String).into_bytes()); ($t:ty) => (iter.next().unwrap().parse::<$t>().unwrap()); } let n = scan!(u64); let ans = match n { 1 => ModInt::new(12), 2 => ModInt::new(65), _ => (ModInt::new(n * 6 + 1).pow(2) - ModInt::one()) * ModInt::new(2).inv() - ModInt::new(n * n - 1), }; println!("{}", ans); }