#include<bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
template<typename T_>void operator+=(vector<T_>&x,const T_&y){x.push_back(y);}
const int p=1e9+7;
int n;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	freopen("barrack.in","r",stdin);
	freopen("barrack.out","w",stdout);
	cin>>n;
	cout<<1ll*n*(n-1)/2%p<<'\n';
	return 0;
}

