#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cassert>

#include<cmath>
#include<functional>
#include<algorithm>

#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<bitset>
#include<tuple>

#define TEST {IS_TEST=true;}

using namespace std;
using ll = int_fast64_t;
using v_bool = vector <bool>;
using v_ll = vector <ll>;
using v_std = vector <string>;
using p_ll = pair <ll,ll>;
using vv_ll = vector <vector <ll> >;
using vp_ll = vector < p_ll >;

bool IS_TEST=false;
ll ll_min=1LL<<63;
ll ll_max=~ll_min;
ll MOD = 1000000007;

/*
template<class T> bool show_nl(const T&){ return true;}
bool show_nl(const ll&){ return false;}
template<class T,class S> bool show_nl(const pair<T,S>&){ return false;}
*/

template<class T> bool show_nl(const T&){ return false;}
bool show_nl(const string&){ return true;}
template<size_t N> bool show_nl(const bitset<N>&){ return true;}
template<class T> bool show_nl(const vector<T>&){ return true;}
template<class T,class S> bool show_nl(const queue<T,S>&){ return true;}
template<class T,class S,class U> bool show_nl(const priority_queue<T,S,U>&){ return true;}
template<class T,class S> bool show_nl(const stack<T,S>&){ return true;}
template<class T,class S> bool show_nl(const set<T,S>&){ return true;}
template<class T,class S> bool show_nl(const multiset<T,S>&){ return true;}
template<class T> bool show_nl(const unordered_set<T>&){ return true;}
template<class T,class S,class U> bool show_nl(const map<T,S,U>&){ return true;}
template<class T,class S,class U> bool show_nl(const multimap<T,S,U>&){ return true;}
template<class T,class S> bool show_nl(const unordered_map<T,S>&){ return true;}

template<class T> void show(const T& x,bool newline=false){
  if (!IS_TEST) return;
  cout << x; if (newline) cout << " <#>" <<  endl;
}
void show(const string& x,bool newline=true){
  if (!IS_TEST) return;
  cout << x; if (newline) cout << endl;
}
template<class T,class S> void show(const pair<T,S>& x,bool newline=false){
  if (!IS_TEST) return;
  cout << "{ " << x.first << " " << x.second << " }";
  if (newline) cout << " <#>" <<  endl;
}
template<class T> void show_common3(const T&x){
  if (!IS_TEST) return;
  auto itr=x.begin();
  if (x.begin()==x.end()) {cout<<"<NULL>"<<endl;return;}
  if (show_nl(*itr)){
    cout << "--------------------------------" << endl;
    auto itr=x.begin();
    while(itr!=x.end()){ show(*itr); itr++;}
    cout << "--------------------------------" << endl;
  }else{
    if (itr==x.end()){ cout<<endl; return;}
    while(true){
      show(*itr);itr++;
      if (itr==x.end()) break; else cout << " ";
    }
    cout << endl;
  }
}
template<class T> void show(const vector<T>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T,class S> void show(const set<T,S>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T,class S> void show(const multiset<T,S>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T> void show(const unordered_set<T>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T,class S,class U> void show(const map<T,S,U>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T,class S,class U> void show(const multimap<T,S,U>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}
template<class T,class S> void show(const unordered_map<T,S>& x,bool newline=false){
  if (!IS_TEST) return; show_common3(x);
}

void load(ll& x){ cin >> x;}
void load(string& x){ cin >> x;}
void load(v_ll& v,ll b,ll e){
    v.assign(e+1,0);
    for(ll i=b;i<e;i++)cin >> v[i];
}
v_ll loadvec0(ll n){
    v_ll v(n+1,0);
    for(ll i=0;i<n;i++)cin >> v[i];
    return v;
}
v_ll loadvec1(ll n){
    v_ll v(n+2,0);
    for(ll i=1;i<=n;i++)cin >> v[i];
    return v;
}

void disp(const ll& x){ cout << x << endl;}
void disp(const string& x){ cout << x << endl;}
void disp(const v_ll& v,ll b,ll e){
    for(ll i=b;i<e;i++){
        if (i!=b) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

v_ll arange(ll n){
    v_ll v(n+1,0);
    for(ll i=0;i<=n;i++)v[i]=i;
    return v;
}

ll vec_sum(const v_ll& v,ll b,ll e){
    ll ans=0;
    for(ll i=b;i<e;i++)ans+=v[i];
    return ans;
}


ll max(ll x,ll y){return x>y?x:y;}
ll max(ll x,ll y, ll z){return max(max(x,y),z);}
ll max(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=max(ans,*b);b++;}
    return ans;
}

ll min(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y, ll z){return min(min(x,y),z);}
ll min(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) {ans=min(ans,*b);b++;}
    return ans;
}

ll mid(ll x,ll y,ll z){
    if (y>=x && x>=z) return x;
    if (z>=x && x>=y) return x;
    if (x>=y && y>=z) return y;
    if (z>=y && y>=x) return y;
    if (x>=z && z>=y) return z;
    if (y>=z && z>=x) return z;
    return x;
}

ll gcd(ll x,ll y){
    if(x<0)x=-x; if(y<0)y=-y;
    while(y>0){ x%=y; swap(x,y); }
    return y;
}
ll gcd(ll x,ll y, ll z){return gcd(gcd(x,y),z);}
ll gcd(v_ll::iterator b,v_ll::iterator e){
    ll ans=0;
    while (b<e) ans=gcd(ans,*b);
    return ans;
}

ll lcm(ll x,ll y){
    ll z=x*y; if(x<0)x=-x; if(y<0)y=-y;
    while(y>0){ x%=y; swap(x,y); }
    return z/y;
}
ll lcm(ll x,ll y, ll z){return lcm(lcm(x,y),z);}
ll lcm(v_ll::iterator b,v_ll::iterator e){
    ll ans=1;
    while (b<e) ans=lcm(ans,*b);
    return ans;
}

ll v_sum(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans+=*b; b++;}
    return ans;
}
ll v_xor(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans^=*b; b++;}
    return ans;
}
ll v_eq(v_ll::iterator b,v_ll::iterator e){
    ll ans=*b;
    while (b<e) { ans^=~*b; b++;}
    return ans;
}


template<class T> void refl_max(T& x,const T& y){ if (x>=y) return; x=y; }
template<class T> void refl_min(T& x,const T& y){ if (x<=y) return; x=y; }

template<class T,class S> void refl_max(T& x,const T& y,S& xx,const S& yy){
  if (x>=y) return; x=y; xx=yy;
}
template<class T,class S> void refl_min(T& x,const T& y,S& xx,const S& yy){
  if (x<=y) return; x=y; xx=yy;
}

/*O(logN)*/
ll sqrt_ll(ll n){
  assert(n>=0);
  ll ok = 0,ng = n+1;
  while(ok-ng>1||ng-ok>1){ ll m=(ok+ng)/2; if (m*m<=n) ok=m; else ng=m;}
  return ok;
}

ll N;
v_ll L;
int main(){
  cin >> N;
  L=loadvec1(N);
  ll ans=0;
  sort(L.begin()+1,L.begin()+1+N);
  for(ll i=1;i<=N;i++){
    for(ll j=i+1;j<=N;j++){
      ll x= lower_bound(L.begin()+1,L.begin()+1+N,L[i]+L[j])-L.begin();
      if (x-(j+1)>0) ans+=x-(j+1);
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 256