#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstring>
#include <deque>
#include <set>
#include <iterator>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int >> vvi;

#define p0(a) cout << a
#define p_(a) cout << a << " "
#define p1(a) cout << a << "\n"
#define pf(a) cout << fixed << setprecision(10) << a << "\n"
#define c1(a) cin >> a
#define c2(a,b) cin >> a >> b
#define c3(a,b,c) cin >> a >> b >> c
#define c4(a,b,c,d) cin >> a >> b >> c >> d
#define FL(i,a,b) for(ll i = a ; i < b ; i++)
#define FLI(i,a,b) for(ll i = b-1 ; i >=a ; i--)
#define itor(it,x) for(auto it=x.begin();it!=x.end();it++)
#define itori(it,x) for(auto it=x.end();it!=x->begin();it--)
#define pb push_back
#define F first
#define S second
#define be(v) v.begin(),v.end()
#define ber(v) v.rbegin(),v.rend()
#define bins(v,x) binary_search(be(v),x)
#define gcd __gcd
#define maxe *max_element
#define mine *min_element

#define umll unordered_map<ll,ll>
#define umlb unordered_map<ll,bool>
#define umlvl unordered_map<ll,vl>
#define usl unordered_set<ll>
#define umsl unordered_map<string,ll>
#define umcl unordered_map<char,ll>
#define umsb unordered_map<string,bool>
#define mll map<ll,ll>
#define pll pair<ll,ll>

#define shalin ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define MOD1 100000007
#define MOD2 1000000005
#define INF 10e20
#define PI 3.141592653589793
#define E 2.71828

ll Max(ll a, ll b)
{
    return a>b ?a:b;
}

ll Min(ll a, ll b)
{
    return a<b ?a:b;
}
void Swap(ll *a, ll *b)
{
    ll temp;
    temp = *a;
    *a = *b;
    *b = temp;
}
bool isPrime(ll n)
{
    ll temp = sqrt(n) + 1;
    FL(i,2,temp)
   {
      if(n%i == 0) return false;
   }
    return true;
}

vl Divisors(ll n)
{
    vl A;
    ll m = sqrt(n) + 1;
    FL(i,1,m)
    {
        if(n%i == 0)
        {
            A.push_back(i);
            if(i != n/i)
            {
                A.push_back(n/i);
            }
        }
    }
    return A;
}
/*
// Graphs

vector<ll> adj[N];
bool visit[N];

void dfs( ll n)
{
    if(visit[n]) return;
    visit[n] = true;
    // process n;
    for(auto u : adj[n])
    {
        dfs(u);
    }
}
ll dist[N];
void bfs(ll x)
{
    visit[x] = true;
    dist[x] = 0;
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll s = q.front();q.pop();
        // process s;
        for(auto u : adj[s])
        {
            if(visit[u]) continue;
            visit[u] = true;
            dist[u] = dist[s] + 1;
            q.push(u);
        }
    }
}

vector<tuple<int,int,int> > edges;
ll dist[N+1];
FL(i,1,N+1) dist[i] = INF;
void bellman_ford(ll x)
{
    dist[x] = 0;
    FL(i,1,N)
    {
        for(auto e : edges)
        {
            ll a,b,w;
            tie(a,b,w) = e;
            dist[b] = Min(dist[b],dist[a]+w);
        }
    }
}

vector<pair<ll,ll>> adj[N+1];
bool processed[N+1];
ll dist[N+1];
void djikshtra(ll x)
{
    dist[x] = 0;
    priority_queue<pair<ll,ll>> q;
    q.push({0,x});
    while(!q.empty())
    {
        ll a = q.top().second;
        q.pop();
        if(processed[a]) continue;
        processed[a] = true;
        for(auto u : adj[a])
        {
            ll b = u.first;
            ll w = u.second;
            if(dist[b] > dist[a] + w)
            {
                dist[b] = dist[a] + w;
                q.push({-dist[b],b});
            }
        }
    }
}
void dfs_tree(ll s, ll e)
{
    //process s;
    for(auto u : adj[s])
    {
        if(u ! = e)
        {
            dfs_tree(u,s);
        }
    }
}

*/
///////
ld Mean(vl A)
{
    ll Answer = 0;
    ll n = A.size();
    FL(i,0,n)
    {
        Answer+= A[i];
    }
    return (ld)Answer/(ld)n;
}
ll Mode(vl A)
{
    sort(be(A));
    ll n = A.size();
    ll Answer = A[0];
    ll value = 1;
    ll temp = 1;
    FL(i,1,n)
    {
        if (A[i] == A[i-1])
        {
            temp++;
        }
        else
        {
            if (temp >= value)
            {
                Answer = A[i-1];
                value = temp;
            }
            temp = 1;
        }
    }
    vl R ; R.pb(value) ; R.pb(Answer) ;
    //return R;
    //return value;
    return Answer;
}
ld Median(vl A)
{
    sort(be(A));
    ll n = A.size();
    if (n%2 == 0)
    {
        return (A[n/2] + A[n/2 - 1])/2.0;
    }
    else
    {
        return A[n/2];
    }
}

ll Bound(vl A,ll n,bool upper)
{
    ll i = 0;
    ll j = A.size()-1;
    ll val = 0;
    ll mid ;
    while(i<=j)
    {
        mid = (i + j)/2;
        if(A[mid] == n)
        {
            return n;
        }
        else if(A[mid] > n)
        {
            j = mid - 1;
        }
        else
        {
            i = mid + 1;
        }
    }
    if(upper)
    {
        if(A[mid] > n) return A[mid];
        else if (mid == A.size()-1) return A[mid];
        else return A[mid+1];
    }
    else
    {
        if(A[mid] < n) return A[mid];
        else if (mid == 0) return A[mid];
        else return A[mid-1];
    }

}

ll lcm(ll a, ll b)
{
    ll temp = gcd(a,b);
    return (a*b)/temp ;
}

ll log_base(ll base, ll number)
{
    ld x = log10((ld)base);
    ld Answer = log10((ld)number);
    Answer /= x;
    return (ll)Answer;
}

ll solve()
{

}

//\\//\\//\\//\\//\\//\\////\\//\\//\\//\\//\\//\\////\Shalin_Jain////\\//\\//\\//\\//\\//\\////\\//\\//\\//\\//\\//\\//\\//

int main()
{
    shalin;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    c1(n);
    map<ll,ll> A;
    ll val;
    FL(i,0,n)
    {
        c1(val);
        if(A.find(val) == A.end())
        {
            A[val] = 1;
        }
        else
        {
            A[val]++;
        }
    }
    vl B;
    itor(it,A)
    {
        B.pb(it->first);
    }
    sort(be(B));
    ll Answer = 0;
    if(B.size() < 3)
    {
        p0(Answer);
        return 0;
    }
    ll i = 0;
    ll j = 1;
    while(i < n-2)
    {
        ll k = j+1;
        while((B[k] < B[i] + B[j]) && (k < n))
        {
            Answer += A[B[k]]*A[B[i]]*A[B[j]];
            k++;
        }
        j++;
        if(j == n-1)
        {
            i++;
            j = i+1;
        }
    }
    p0(Answer);
    return 0;
}



Measured memory_bytes: 3676