#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int threediv(std::vector<int> &nums) {
    if (nums.size() < 2)
        return 0;

    int i = 0;
    int j = 1;
    int k = 2;

    int threedivs = 0;

    // N(NlogN)
    sort(nums.begin(), nums.end());

    // O(N)?
    bool move_k = false;
    bool move_j = false;
    for (int asdf = 0; asdf < 1000; asdf++) {
        if (nums[j] % nums[i] == 0 && nums[k] % nums[j] == 0) {
           // std::cout << "Triplet { " << nums[i] << ", " << nums[j] << ", " << nums[k] << " }\n";
            ++threedivs;
        }

        // Keep divisible pairs together as much as possible
        if (nums[j] % nums[i] == 0) {
            if (k < nums.size() - 1) {
                ++k;
                continue;
            }
            move_k = true;
        }

        if (j == k - 1 && k == nums.size() - 1) {
            move_k = true;
            move_j = true;
            goto inc_i;
        }

inc_i:
        if (k - j > 1)
            ++j;
        else if (k < nums.size() - 1)
            ++k;
        else if (j - i > 1)
            ++i;

        // Reset j and k
        if (move_j) {
            j = i + 1;
            move_j = false;
        }

        if (move_k) {
            k = j + 1;
            move_k = false;
        }

        // We have just looked at the triplet with (i,j,k) = (-3,-2,-1)
        if (i >= j && j >= k && k >= nums.size())
            break;
    }

    return threedivs;
}


int main() {
    int n;
    std::vector<int> nums;
    nums.reserve(n);

    cin >> n;
    for (int _n = 0; _n < n; ++_n) {
        int num;
        cin >> num;
        nums.push_back(num);
    }

    int threedivs = threediv(nums);
    std::cout << threedivs;
}
