"use strict"
// input data
function main(input) {
    const n = Number(input.split('\n')[0].split(' ')[0]);
    const s = String(input.split('\n')[1].split(' '));

    // const N = factorial(n);
    let count = 0;
    for (let i = 1; i <= n; i++) {
        for (let j = i; j <= n; j++) {
            for (let k = j; k <= n; k++) {
                if ((s[i-1] !== s[j-1] && s[j-1] !== s[k-1] && s[i-1] !== s[k-1]) && ((j-i)!==(k-j))) {
                    count++;
                }
            }
        }
    }
    console.log(count);
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));