#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin ("nrtri.in") ;
ofstream cout ("nrtri.out") ;
int n, S, p ;
int v[805] ;
int main()
{
    int x, st, dr, mij, triunghiuri = 0 ;
    cin >> n ;
    for (int i = 1 ; i <= n ; i ++)
        cin >> v[i] ;
    sort (v + 1, v + n + 1) ;
    for (int i = 1 ; i <= n - 2 ; i ++)
    {
        for (int j = i + 1 ; j < n ; j ++)
        {
            S = v [i] + v [j] ;
            p = -1 ;
            st = j + 1 ;
            dr = n ;
            mij = ( st + dr ) / 2 ;
            while ( st <= dr )
            {
                if ( v [ mij ] == S )
                {
                    p = mij ;
                    st ++ ;
                }
                else if ( v [ mij ] < S )
                {
                    st = mij + 1 ;
                }
                else
                {
                    dr = mij - 1 ;
                }
                mij = ( st + dr ) / 2 ;
            }
            if ( p == -1 )
                p = dr ;
            triunghiuri = triunghiuri + p - j ;
        }
    }
    cout << triunghiuri ;
    return 0 ;
}