import java.util.*; public class Main { public static long MOD = (long)Math.pow(10, 6) + 7; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long inv = func(4, MOD - 2); long t = 1; n = n % MOD; if(n % 2 == 0) { t = (n * n) % MOD; t = (t * inv) % MOD; t = (t + n) % MOD; } else { t = (n * n + MOD - 1) % MOD; t = (t * inv) % MOD; t = (t + n) % MOD; } System.out.println(t); } public static long func(long a, long x) { if(x == 0) return 1; if(x % 2 == 0) { long t = func(a, x / 2); return (t * t) % MOD; } else { long t = func(a, x / 2); t = (t * t) % MOD; return (a * t) % MOD; } } }