#include <stdio.h>
#include <stdlib.h>
 
#define MAXN 800
 
int n, result;
int v[MAXN];
 
void read()
{
    scanf("%d",&n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&v[i]);
    }
}
 
void print()
{
    printf("%d\n",result);
}
 
int cmp (const void *a, const void *b)
{
    return *((int *) a) - *((int *) b);
}
 
void compute()
{
    qsort(v,n,sizeof(int),cmp);
    for (int k = n - 1; k > 1; --k) {
        int i = 0, j = k - 1;
        while (i < j) {
            int sum = v[i] + v[j];
            if (sum >= v[k]) {
                result += j - i;
                --j;
            } else {
                ++i;
            }
        }
    }
}
 
int main()
{
    freopen("nrtri.in","r",stdin);
    freopen("nrtri.out","w",stdout);
    read();
    compute();
    print();
    return 0;
}