import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	// 題意と同様の列で「第n項から先」ではなく「第k項から先」がすべて同じ数であるもの
	// の個数をxs[k]とする
	// 求めるものはxs[n]
	// あたまの数字で場合分けすると xs[k] = n xs[k - 2] + sum(i = 2 .. k - 1) xs[k - i] + sum(i = k .. n) n
	// xs[1] = n, xs[2] = n * n, xs[3] = n * n + (n - 1) * n
	
	int n = read.to!int;
	
	long[] xs;
	xs.length = max(n + 1, 4);
	xs[1] = n, xs[2] = n * n, xs[3] = n * n + (n - 1) * n;
	
	const long mod = 1_000_000_007;
	
	for(int k = 4; k <= n; k ++){
		xs[k] = xs[k - 1] + ((n + 1) * xs[k - 2]) - (n * xs[k - 3]) - n;
		xs[k] %= mod;
		}
	
	xs[n].writeln;
	}