#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
//#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

int D;
string str,s,u;
vector<int>c(26);
vector<int>t(366),t0(366);
vector<vector<int>> ss(366, vector<int>(26));
//vector<vector<int>> last(365, vector<int>(26));
vector<int> last(26),last0(26);
int satisfaction=0;
int init_score;

int init(){
    vector<int>c_copy(26);
    c_copy=c;
    rsort(c_copy);
    int now=1;
    srand( time(NULL) );
    for (int i = 0; i < D; ++i) {
        t[i]=now;
        //now=min(now+1,26);
        now=rand () % 26+1;
        if(now>26)now=1;
    }

    return 0;

}

int score(){
    satisfaction=0;
    last=last0;
    for (int d = 0; d < D; ++d) {
        int i = t[d]-1;
        satisfaction+=ss[d][i];

        last[i]=d+1;
        for (int cc = 0; cc < 26; ++cc) {
            satisfaction-=c[cc]*((d+1)-last[cc]);
        }
        //cout<<satisfaction<<endl;
    }

    return satisfaction;
}
int hajime = clock();
int loop(){
    int old_score=init_score;
    int new_score=0;
    srand( time(NULL) );
    int cnt=0;
    while(cnt<=20000000){
        if ((clock() - hajime) > 1.95 * CLOCKS_PER_SEC) break;
        int d=rand()%365+1;

            int now=t[d];
            //t[d]++;
            //t[d]=min(t[d]+1,26);
            t[d]=min(rand()%26+1,26);
            new_score=score();
            if(new_score<=old_score){
                t[d]=now;

            }else{
                old_score=new_score;
                //cout<<cnt<<" "<<d<<" "<<new_score<<endl;
            }



        cnt++;
    }



    return 0;
}

int main() {
    IOS;
    prec;

    int n,ans=0;
    cin>>n;
    vector<int>L(n);
    for (int i = 0; i < n; ++i) {
        cin>>L[i];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            for (int k = j; k < n; ++k) {
                int sum=L[i]+L[j]+L[k];
                if(max({L[i],L[j],L[k]})<sum-max({L[i],L[j],L[k]}) and (L[i]!=L[j]) and (L[k]!=L[j]) and (L[i]!=L[k])){
                    ans++;
                }
            }
        }
    }

cout<<ans;




    cout<<endl;
    return 0;
}


Measured memory_bytes: 3740