#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int solution[3] = {0, 0, 0};
    vector<int> seq;
    int counter = 0;

    for(int i = 0; i < n; i++){
        int number;
        cin >> number;
        seq.push_back(number);
    }

    sort(seq.begin(), seq.end());

    for(int i = 0; i < seq.size(); i++){
        solution[0] = seq.at(i);
        for(int j = i + 1; j < seq.size(); j++){
            if(seq.at(j) % solution[0] == 0){
                solution[1] = seq.at(j);
                for(int z = j + 1; z < seq.size(); z++){
                    if(seq.at(z) % solution[1] == 0){
                        solution[2] = seq.at(z);
                        counter++;
                    }
                }
            }
        }
    }
    cout << counter << endl;

    return 0;
}
