#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>
#define setbits(x) __builtin_popcountll(x)
#define md (ll)1e9 + 7
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define f(i, j, n) for (ll i = j; i < n; i++)
#define r(i, j, n) for (ll i = n - 1; i >= j; i--)

void solve()
{
    ll b,c;
    cin>>b>>c;
    ll p=c,n=c-1;
    if(b<0)
        swap(p,n);
    else if(b==0)
        p=c,n=c;
    b=abs(b);
    ll l1=b+(n-1)/2;
    ll r1=b-p/2;
    ll l2=-(b-(p-1)/2);
    ll r2=-b-n/2;
    ll ans=l1-r1+1 + l2-r2+1;
    ans-=max(0ll,l2-r1+1);
    cout<<ans;
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("inpput.txt", "r", stdin); //freopen("op.txt", "w", stdout);
#endif
    ll test_cases = 1;
    //cin >> test_cases;
    for (ll t = 1; t <= test_cases; t++)
        solve(),cout<<"\n";;
    //cerr<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";
    return 0;
}
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
using vi64 = vector<i64>;
using vvi64 = vector<vi64>;
using vvvi64 = vector<vvi64>;
using u64 = uint64_t;

#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)

void run() {
  i64 n;
  cin >> n;
  vi64 as(n);
  rep(i, 0, n) { cin >> as[i]; }
  sort(begin(as), end(as));
  i64 ret{0}, pre{0};
  rep(i, 1, n) {
    pre += (as[i] - as[i - 1]) * i;
    ret += pre;
  }
  cout << ret << endl;
}

int main() {
  cin.tie(nullptr);
  cout.precision(std::numeric_limits<double>::max_digits10);
  run();
  return 0;
}
