#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int n,i,x,p,tri,s,j;
vector<int> a;
vector<int> ::iterator it;
int cb(int li, int ls, int s)
{
    int m;
    while(li<=ls)
    {
        m=(li+ls)/2;
        if(a[m]==s) return m;
        if(a[m]<s) li=m+1;
        else ls=m-1;
    }
    return ls;
}
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++) cin>>x,a.push_back(x);
    sort(a.begin(),a.end());
    for(i=0;i<n-2;i++)
        for(j=i+1;j<n-1;j++)
        {
            s=a[i]+a[j];
            p=cb(j+1,n-1,s);
            while(a[p+1]==a[p]) p++;
            if(p>j) tri+=p-j;
        }
    cout<<tri;
    return 0;
}