/*
     
     _____________    _____________    _____________	          _____________    _____________
    (  ___________)  |  _________  )  (___________  )	         (___________  )  (  ___________)
    ( (		     | |         | )	          | )            	     ) )  ( (
    ( (___________   | |_________| )   ___________| )	          ___________) )  ( (___________
    (___________  )  |  ___________)  |  _________  )            (  ___________)  (  _________  )
                ) )  | |	      | |         | )  	         ( (              ( (         ) )
     ___________) )  | |___________   | |_________| )   ______   ( (___________   ( (_________) )
    (_____________)  |_____________)  |_____________)  (______)  (_____________)  (_____________)
    			
    			
    Name   : Abdus Sahid
    handle : sea_26
    	
    Find me through this handle in others online judge
    Or easily search on Google through this handle.
    		   
    		   
    Practice makes a man perfect.
    Don't lose faith.
    	
    	
 */
     
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
     
using namespace __gnu_pbds;
using namespace std;
     
template <typename T>
      using ordered_set = tree<T, null_type, less<T>,
          rb_tree_tag, tree_order_statistics_node_update>;
     
     
using ll = long long;
using ld = long double;
     
typedef pair<int, int> PII;
typedef pair<ll, int> PLI;
typedef pair<int, ll> PIL;
typedef pair<ll, ll> PLL;
     
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<int> VI;
typedef vector<ll> VL;
     
priority_queue<int> pq;
     
const int M = 1e9 + 7;
const ll FFTM = 998244353;
const ld eps = 1e-9;
const ld PI = acos(-1.0);
// const double pi = atan2(0, -1);
// const double PI = 4 * atan(1);
// const double pi = 2*cos(0.0);
     
const int iinf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
     
#define mp make_pair
#define eb emplace_back
#define pf push_front
#define pb push_back()
#define ppb pop_back()
#define ep emplace
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define sz size();
     
#define bp(n)  __builtin_popcount(n)
#define bclz(n) __builtin_clzll(n)
#define bctz(n) __builtin_ctzll(n)
#define bip(n) __builtin_parity(n)
     
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define rvsort(v) sort(all(v),greater<int>())
#define mnv(v) *min_element(all(v))
#define mxv(v) *max_element(all(v))
#define ita(v) iota(all(v), 0)
#define acm(v, ini) accumulate(all(v),ini)
#define uni(v) vsort(v),(v).erase(unique(all(v)), (v).end())
#define smp(container, element) (container.find(element) != container.end())
#define vp(container, element) (find(all(container),element) != container.end())
     
     
#define ub upper_bound
#define lb lower_bound
#define cr(n) cbrt(n)
#define msz(a) memset(a, 0, sizeof(a))
#define msm(a) memset(a, 0xff, sizeof(a))
#define fpre(n) fixed << setprecision(n)
     
#define rep(n) for(int i=0; i<n; i++)
#define per(n) for(int i=n-1; i>=0; i--)
#define lrep(p,q) for(int j=p; j<=q; j++)
#define perl(p,q) for(int i=p; i>=q; i--)
     
     
#define boost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
     
     
template< typename T> inline T MAX(T a, T b){ return a ^ ((a ^ b) & -(a < b)); }
template< typename T> inline T MIN(T a, T b){ return b ^ ((a ^ b) & -(a < b)); }
template< typename T> void SWAP(T &a, T &b){ a = ((a) ^= (b)),  b = ((b) ^= (a)),  a = ((a) ^= (b)); }
template< typename T> inline T sqr(T x){ return x * x; }
     
template< typename T> inline T gcd(T a, T b){ while (b) b ^= a ^= b ^= a %= b; return a; }
template< typename T> T exgcd(T a, T b, T& x, T& y){ if(!b){ x = 1; y = 0;return a;} else{ T g = exgcd(b,a%b,y,x); y -= (a/b)*x; return g;}}
//template< typename T> T gcdextd(T a, T b, T& x, T& y){ if(!a) { x = 0; y = 1; return b; }  T x1,y1,d; d = gcdextd(b % a, a, x1, y1);  x = y1 - (b / a) * x1; y = x1; return d; }
template< typename T> inline T lcm(T a, T b){ return (a / gcd(a,b)) * b; }
     
template< typename T> T icbrt(T mul){ T r = cbrt(mul) + 1; while(r * r * r > mul) r--; return r; } /// 54229668
template< typename T> void tpns(T n){ per(30){ if(n & (1 << i)) pq.push(1 << i); } }
     
template< typename T> inline T mod(T a, T b){ return a >= b ? a % b : a; }
template< typename T> T binpow(T n, T p){ T res = 1; while(p > 0){ if(p & 1) res *= n; n *= n; p >>= 1; } return res;}
template< typename T> T bigmod(T n, T p, T M){ n %= M; T res = 1; while(p > 0){ if(p & 1)res = ((res%M) * (n % M)) % M; n = ((n%M) * (n%M))%M; p >>= 1; } return res;}
template< typename T> T modInv(T a, T m){return bigmod(a, m-2, m);}
     
     
void ReT(){ cout << "\nReqired Time = " << fpre(7) << double(clock()) / CLOCKS_PER_SEC  << " Sec"<< endl; exit(0);}




int main(){
    	
    boost 
    	
    ll n;
	cin >> n;
	
	cout << ((n-1)*n)/2 << endl;
    	
    //ReT();
    
return 0;
}


Measured memory_bytes: 256