#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpl = vector<pair<ll, ll>>;
using pll = pair<ll, ll>;
#define rep(i, k, n) for(ll i = k; i < n; i++)
#define pb push_back
#define mp make_pair

int main(){
    ll n; cin >> n;
    vll a(n);
    rep(i, 0, n) cin >> a[i];

    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i, 0, n){
        ans += ((2*i+1) - n) * a[i];
    }

    cout << ans << endl;
}

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

#define ar array<ll, 2>
#define ll long long
#define in insert
#define pb push_back
#define pii pair<ll,ll>
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define For(i, n) for(ll i = 0; i < n; i++)
#define Rev(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, n) for(ll i = 1; i <= n; i++)
#define REV(i, n) for(ll i = n; i >= 1; i--)
#define Rep(i,a,b) for(ll i = a; i <= b; i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int) (x).size()

void solve()
{
  long double x,y,r;
  cin>>x>>y>>r;
  ll ans=0;
  r=nextafter(r,1e14);
  for(ll i=ceil(x-r);i<=floor(x+r);i++)
  {
  	long double count=sqrt((r*r)-(x-i)*(x-i));
  	ans+=floor(y+count)-ceil(y-count)+1;
  }
  cout<<ans<<endl;
   return;
}

int main()
{
  ios::sync_with_stdio(0);  cin.tie(0);
  solve();
  return 0;
}

