process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const list = lines[1].split(" ").map(v=>v-0);
    list.sort((a,b)=>a-b);
    let ans = 0;
    for(let i=0;i<list.length;i++){
        for(let j=i+1;j<list.length;j++){
            if(list[i] == list[j]) continue;
            for(let k=j+1;k<list.length;k++){
                if(list[j] == list[k]) continue;
                if(list[k]< list[i]+list[j]) ans++;
            }
        }
    }
    
    console.log(ans);
});

check = (a)=>{
    return a.toString()===a.toString().split("").reverse().join("")?1:0;
}
