long n;main(t){scanf("%ld",&n);n%=(t=1e6+7)*2;n=!printf("%ld",(n*n/4+n)%t);}