#include<bits/stdc++.h>
//#pragma GCC optimize "trapv"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define fast_az_fuk      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll               long long
#define lll              __int128
#define ull              unsigned ll
#define ld               long double 
#define pb               push_back 
#define pf               push_front
#define dll              deque<ll> 
#define vll              vector<ll>
#define vvll             vector<vll> 
#define pll              pair<ll,ll> 
#define vpll             vector<pll>
#define dpll             deque<pll>
#define mapll            map<ll,ll>
#define umapll           umap<ll,ll>
#define endl             "\n" 
#define all(v)           v.begin(),v.end() 
#define ms(a,x)          memset(a,x,sizeof(a))
#define random(l,r,T)    uniform_int_distribution<T>(l,r)(rng)


//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;

#ifdef LOCAL
    #include <debug.h>
#endif

template<typename T> istream& operator >>(istream &in,vector<T> &v){ for(auto &x:v) in>>x; return in;}
template<typename T> ostream& operator <<(ostream &out,const vector<T> &v){ for(auto &x:v) out<<x<<' '; return out;}
template<typename T1,typename T2> istream& operator >>(istream &in,pair<T1,T2> &p){ in>>p.first>>p.second; return in;}
template<typename T1,typename T2> ostream& operator <<(ostream &out,const pair<T1,T2> &p){ out<<p.first<<' '<<p.second; return out;}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
template<class T>using uset=unordered_set<T,custom_hash>;


int32_t main()
{
    #ifdef LOCAL
        freopen("error.txt", "w", stderr);
    #endif
    // clock_t clk = clock();
    fast_az_fuk
    ll n; cin>>n; vll a(n); cin>>a;
    mapll hash; for(ll x:a) hash[x]++;
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans += n - hash[a[i]];
    }
    ans /= 2;
    cout<<ans;
    // cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
    return 0;
}

#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define REP(i,n) for(int i = 0;i < n;i++)
#define RNG(i,s,n) for(int i = s;i <= n;i++)
#define _RNG(i,e,s) for(int i = e;i >= s;i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define dup(x,y) (x + y - 1) / (y)
#define all(x) (x).begin(),(x).end()
#define lb(x,key) lower_bound(all(x) , (key))
#define ub(x,key) upper_bound(all(x) , (key))

template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; }else return false; }
template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; }else return false; }

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout<<"["<<#a<<","<<#b<<"] = "<<"["<<a<<","<<b<<"]\n"
#define debug3(a,b,c) cout<<"["<<#a<<","<<#b<<","<<#c<<"] = "<<"["<<a<<","<<b<<","<<c<<"]\n"
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
    cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
    return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
    cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
    return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
    cout << "{" << p.first << "," << p.second << "}" << '\n';
    return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
    for (auto& i : arr)cin >> i; return in;
}
template<class S,class T> istream &operator >> (istream& in,pair<S,T>& p){
    cin >> p.first >> p.second; return in;
}

#define F first
#define S second


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll ans = 0;
    
    ll n,k;
    cin >> n >> k;
    k = abs(k);
    for(ll i = 2;i + k <= 2 * n;i++){
        ll p,q;
        if(i > n){
            p = 2 * n - i + 1;
        }else{
            p = i - 1;
        }
        if(i + k > n){
            q = 2* n - (i + k) + 1;
        }else{
            q = i + k - 1;
        }
        ans+= p * q;
    }
    cout << ans << '\n';
    return 0;
}

