#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define aint(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,a[805],tree[60005];
void update(ll pos,ll val){
for(;pos<=60000;pos+=pos&(-pos)){
    tree[pos]+=val;
}
}
ll query(ll pos){
ll res=0;
for(;pos;pos-=pos&(-pos)){
    res+=tree[pos];
}
return res;
}
int32_t main(){
CODE_START;
ifstream cin("nrtri.in");
ofstream cout("nrtri.out");
cin>>n;
ll mx=0;
for(ll i=1;i<=n;i++)
{
    cin>>a[i];
    update(a[i],1ll);
    mx=max(mx,a[i]);
}
ll ans=0;
sort(a+1,a+n+1);
for(ll i=1;i<=n;i++)
{
    for(ll j=i+1;j<=n;j++)
    {
        update(a[i],-1ll);
        update(a[j],-1ll);
        ll x=a[i]+a[j];
        x=min(x,mx);
        ans+=query(x);
        if(a[j]-a[i]>=2)
        ans-=query((a[j]-a[i]-1));
        update(a[i],1ll);
        update(a[j],1ll);
    }
}
cout<<ans/3<<endl;
}