Problem:
Score : 400 points

Problem Statement

Given is a number sequence A of length N.

Find the number of integers i \left(1 \leq i \leq N\right) with the following property:

For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5

Solution in Go (1.14.1) (judge verdict: Wrong Answer)

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	var i int64 = 0
	//var j int64 = 0
	//var cnt int64 = 0
	var max int64 = 0

	// 最大値を求める
	for i = 0; i < N; i++ {
		if A[i] > max {
			max = A[i]
		}
	}

	// 素数を求める
	isPrime := make([]bool, max+1)
	for i := 2; i < len(isPrime); i++ {
		isPrime[i] = true
	}
	isPrime[0] = false
	isPrime[1] = false
	for i := 2; i < len(isPrime); i++ {
		if isPrime[i] {
			for j := i * 2; j < len(isPrime); j += i {
				isPrime[j] = false
			}
		}
	}

	// 個数
	countMap := make(map[int64]int64)
	for _, a := range A {
		countMap[a]++
	}

	// 1が1個、または1が2個以上の場合
	if countMap[1] == 1 {
		// x % 1 == 0のみ
		fmt.Printf("%d\n", 1)
		return
	}
	if countMap[1] >= 2 {
		// 全てが x % 1 == 0 になってしまう
		fmt.Printf("%d\n", 0)
		return
	}

	var ans int64 = 0
	for _, a := range A {
		if countMap[a] >= 2 {
			// x % x == 0 になってしまう
			continue
		}
		if isPrime[a] {
			// 素数なので明らか
			ans++
			continue
		}

		// 約数を求める
		fac := make([]int64, 0)
		for i = 2; i*i <= a; i++ {
			if isPrime[i] && a%i == 0 {
				fac = append(fac, i) // 因数
				if i*i != a {
					fac = append(fac, a/i) // 因数で割ったもの
				}
			}
		}

		flag := true
		for _, f := range fac {
			if countMap[f] >= 1 {
				flag = false
				break
			}
		}
		if flag {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func gcdimpl(n, m int64) int64 {
	var i int64 = 0
	for i = 0; i < 10; i++ {
		var t int64 = n - m
		q := false
		if m > t {
			q = true
		}
		if q {
			n = m
		} else {
			n = t
		}
		if q {
			m = t
		} else {
		}
		if m == 0 {
			return n
		}
	}
	return gcdimpl(m, n%m)
}

func gcd(n, m int64) int64 {
	if n > m {
		return gcdimpl(n, m)
	}
	return gcdimpl(m, n)
}

func reduce(x, N int64) int64 {
	return (x * N) >> 32
}