#include <bits/stdc++.h>
using namespace std;

using P = pair<long long, long long>;

long long b, c;

long long solve();

int main() {
  cin >> b >> c;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  vector<P> v;
  v.emplace_back(b - c / 2, b);
  v.emplace_back(-b - (c - 1) / 2, -b);
  v.emplace_back(-b, -(b - (c - 1) / 2));
  if (c >= 2) v.emplace_back(b, b + (c - 2) / 2);
  {
    vector<P> tmp;
    sort(v.begin(), v.end());
    for (auto &[l, r] : v)
      if (l >= r) swap(l, r);
    int len = v.size();
    long long l = v[0].first, r = v[0].second;
    for (int i = 1; i < len; ++i) {
      if (v[i].first <= r)
        r = max(v[i].second, r);
      else {
        tmp.emplace_back(l, r);
        l = v[i].first, r = v[i].second;
      }
    }
    tmp.emplace_back(l, r);
    swap(v, tmp);
  }
  long long res = 0;
  for (auto [l, r] : v) res += r - l + 1;
  return res;
}
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define all(vvv) (vvv.begin(), vvv.end())
#define fastIO cout << fixed << setprecision(7), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
const int N = 1e5 + 9, M = 1e3 + 3, MOD = 1e9 + 7, OO = 1e9;
const ll INF = 1e15;



void runtestcase() {
    int n;
    cin >> n;
    vector<int> vec(n);
    ll total = 0;
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; ++i) {
        total += n - (upper_bound(vec.begin(), vec.end(), vec[i]) - vec.begin());
    }
    cout << total;
}

int main() {
//    freopen("/home/omar/input.in", "rt", stdin);
//    freopen("/home/omar/output.in", "wt", stdout);
#ifdef LOCAL
#endif
    fastIO;
    int t = 1, tt = 1;
//    cin >> t;
    while(t--)
        runtestcase();
}