using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Atcoder
{
    /// <summary>
    /// ContestName : ABC139
    /// Problem : D
    /// </summary>
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            new Program().Solve(sc, new AtMath());
        }
        private void Solve(Scanner sc, AtMath math)
        {
            int n = sc.NextInt();
            long m = 0;
            for(int i = 1; i <= n - 1; i++)
            {
                m += i;
            }
            
            Console.WriteLine(m);
        }
    }

    class AtMath
    {

        public const int MOD = 1000000007;
        public const int INF = 2147483647;
        public const long SINF = 9223372036854775807;

        /// <summary>
        /// 確率統計「nCr」を求める
        /// </summary>
        /// <param name="n"></param>
        /// <param name="r"></param>
        /// <returns></returns>
        public long Ncr(int n, int r)
        {
            int nn = n;
            int rr = 1;
            //nCr
            for (int i = 1; i < r; i++)
            {
                nn *= (n - i);
                rr *= (i + 1);
            }
            return nn / rr;
        }
        /// <summary>
        /// 最大公約数を求める
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public int Gcd(int a, int b)
        {
            if (a < b) { Swap(ref a, ref b); }
            if (a % b == 0) { return b; }
            else { return Gcd(b, a % b); }
        }
        /// <summary>
        /// 入れ替える
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="a"></param>
        /// <param name="b"></param>
        public void Swap<T>(ref T a, ref T b)
        {
            T t = a;
            a = b;
            b = t;
        }
        /// <summary>
        /// 素因数分解
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Dictionary<long, int> Factorize(long n)
        {
            var ret = new Dictionary<long, int>();
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i != 0)
                {
                    continue;
                }

                ret[i] = 0;
                while (n % i == 0)
                {
                    n /= i;
                    ret[i]++;
                }
            }

            if (n > 1)
            {
                if (ret.ContainsKey(n))
                {
                    ret[n]++;
                }
                else
                {
                    ret[n] = 1;
                }
            }

            return ret;
        }
    }
    class Scanner
    {
        public Scanner()
        {
            _pos = 0;
            _line = new string[0];
        }

        const char Separator = ' ';
        private int _pos;
        private string[] _line;

        #region スペース区切りで取得

        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _pos = 0;
            }

            return _line[_pos++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        #endregion

        #region 型変換

        private int[] ToIntArray(string[] array)
        {
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        private long[] ToLongArray(string[] array)
        {
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        private double[] ToDoubleArray(string[] array)
        {
            var result = new double[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = double.Parse(array[i]);
            }

            return result;
        }

        #endregion

        #region 配列取得

        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = Console.ReadLine().Split(Separator);
            _pos = _line.Length;
            return _line;
        }

        public int[] IntArray()
        {
            return ToIntArray(Array());
        }

        public long[] LongArray()
        {
            return ToLongArray(Array());
        }

        public double[] DoubleArray()
        {
            return ToDoubleArray(Array());
        }

        #endregion
    }
}


Measured memory_bytes: 11092