#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define MOD 1000000007
    #define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
    #define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
    //    for(auto& it : m)
    void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
    //  priority_queue<ll int> pq;
    //  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
    //  vector<ll int> v;
    //  vector< pair<ll int,ll int> > v;
    //  set<ll int>::iterator it=s.begin();
    //  unordered_map<  pair<ll int,ll int>, ll int> mp;
       
    ll int power(ll int x, ll int y, ll int p)  
    {  
        ll int res = 1;     // Initialize result  
      
        x = x % p; // Update x if it is more than or  
                    // equal to p 
       
        if (x == 0) return 0; // In case x is divisible by p; 
      
        while (y > 0)  
        {  
            // If y is odd, multiply x with result  
            if (y & 1)  
                res = (res*x) % p;  
      
            // y must be even now  
            y = y>>1; // y = y/2  
            x = (x*x) % p;  
        }  
        return res;  
    }  
     
    void computeLPSArray(string pat, int M, int* lps) 
    { 
        // length of the previous longest prefix suffix 
        int len = 0; 
      
        lps[0] = 0; // lps[0] is always 0 
      
        // the loop calculates lps[i] for i = 1 to M-1 
        int i = 1; 
        while (i < M) { 
            if (pat[i] == pat[len]) { 
                len++; 
                lps[i] = len; 
                i++; 
            } 
            else // (pat[i] != pat[len]) 
            { 
                // This is tricky. Consider the example. 
                // AAACAAAA and i = 7. The idea is similar 
                // to search step. 
                if (len != 0) { 
                    len = lps[len - 1]; 
      
                    // Also, note that we do not increment 
                    // i here 
                } 
                else // if (len == 0) 
                { 
                    lps[i] = 0; 
                    i++; 
                } 
            } 
        } 
    }
    ll int nCrModp(ll int n,ll int r,ll int p) 
    { 
        // Optimization for the cases when r is large 
        if (r > n - r) 
            r = n - r; 
      
        // The array C is going to store last row of 
        // pascal triangle at the end. And last entry 
        // of last row is nCr 
     ll   int C[r + 1]; 
        memset(C, 0, sizeof(C)); 
      
        C[0] = 1; // Top row of Pascal Triangle 
      
        // One by constructs remaining rows of Pascal 
        // Triangle from top to bottom 
        for (ll int i = 1; i <= n; i++) { 
      
            // Fill entries of current row using previous 
            // row values 
            for (ll int j = min(i, r); j > 0; j--) 
      
                // nCj = (n-1)Cj + (n-1)C(j-1); 
                C[j] = (C[j] + C[j - 1]) % p; 
        } 
        return C[r]; 
    } 
    #define MAXN   1000005
  
 multiset<ll int> mul[200005];
      
    int main()
    {
      fastio();
     
     ll int T;
    T=1;
    while(T--)
    {   
     ll int n,i,j,ans=0;
     cin>>n;
     ll int a[n];map<ll int,ll int> mp;
     for(i=0;i<n;i++)
        {cin>>a[i];mp[a[i]]++;}
    
    ll int  ok[1000006]={0};
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        
        for(j=it->first;j<=1e6;j+=it->first)
            ok[j]+=it->second;
        
    }
    for(i=0;i<n;i++)
    {
        if(ok[a[i]]==1)
            ans++;
    }
    cout<<ans<<endl;
     }
     
     
     
     
        return 0;
    }

Measured memory_bytes: 34824