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