#include <bits/stdc++.h>
using namespace std;

const int M=1E9+7;

unsigned int doit(int i,int j){
	if (i==j) return 0;
	if (j-i==1) return 1;
	int mid=(i+j)/2;
	unsigned int ret=(doit(i,mid)+doit(mid+1,j))%M;
	ll p = (1LL * (mid-i+1) * (j-mid))%M;
	ret = (ret + p)%M;
	return ret;
}

int main(){
	int n,cin>>n;
	unsigned int s=doit(0,n-1);
	cout << s+1;
	return 0;
}