package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 解説を参考にした

func main() {
	N := nextInt()
	var ans int
	for i := 1; i <= N; i++ {
		j := N / i
		ans += j * (j + 1) / 2 * i
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	c := make([]int, N+1)
	for i := 1; i <= N; i++ {
		for j := 1; i*j <= N; j++ {
			c[i*j]++
		}
	}
	ans := 0
	for i := 1; i <= N; i++ {
		ans += i * c[i]
	}
	fmt.Println(ans)
}

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 400 points

Problem Statement

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Sample Input 1

4

Sample Output 1

23

We have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	var ans int
	// 1はすべての約数なのでどこかで足す
	// wg := new(sync.WaitGroup)
	// wg.Add(1)
	// go func() {
	for i := 2; i <= N; i++ {
		for j := 1; i*j <= N; j++ {
			ans += i * j
		}
	}
	// 	wg.Done()
	// }()
	// wg.Wait()
	ans += N * (N + 1) / 2
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


package main

import (
	"fmt"
)

func main() {
	var n, ans int64
	fmt.Scan(&n)
	F := make([]int64, n+1)
	for i := int64(1); i < n+1; i++ {
		for j := i; j < n+1; j += i {
			F[j] += j
		}
	}
	for _, f := range F {
		ans += f
	}
	fmt.Println(ans)
}


package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func minFactors(n int) []int {
	mf := make([]int, n+1)
	for i := range mf {
		mf[i] = i
	}
	for i := 2; i*i <= n; i++ {
		if mf[i] != i {
			continue
		}
		for j := i * i; j <= n; j += i {
			if mf[j] == j {
				mf[j] = i
			}
		}
	}
	return mf
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	mf := minFactors(n)

	ans := 0
	for i := 1; i <= n; i++ {
		mp := map[int]int{}
		for j := i; j > 1; j /= mf[j] {
			mp[mf[j]]++
		}
		add := 1
		for _, v := range mp {
			add *= v + 1
		}
		ans += i * add
	}

	puts(ans)
}


package main

import (
	"bufio"
	"flag"
	"fmt"
	"os"
	"sort"
	"strconv"
	"testing"
)

/*-----------Main-----------*/

func main() {
	n := readI()
	a := readIs(n)
	sort.Ints(a)
	del := make([]bool, n)

	for i := 0; i < n; i++ {
		if del[i] {
			continue
		}
		for j := i + 1; j < n; j++ {
			if del[j] {
				continue
			}
			if a[j] == a[i] {
				del[i], del[j] = true, true
			} else if a[j]%a[i] == 0 {
				del[j] = true
			}
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		if !del[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	testing.Init()
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}

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


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		m[a[i]]++
	}
	ans := 0
	for _, e := range a {
		found := true
		if v, ok := m[e]; ok && v > 1 {
			found = false
		}
		for i := 2; i*i <= e; i++ {
			if e%i == 0 {
				if v, ok := m[i]; ok && v >= 1 {
					found = false
					break
				}
				if v, ok := m[e/i]; i != e/i && ok && v >= 1 {
					found = false
					break
				}
			}
		}
		if found {
			ans++
		}
	}
	fmt.Println(ans)
}


package main

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

const MaxA = 1_000_000

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = sc.ReadInt()
	}
	sort.Ints(as)

	count := 0
	sieve := make([]bool, MaxA+1)
	for _, a := range as {
		if !sieve[a] {
			count++
			for j := a; j <= MaxA; j += a {
				sieve[j] = true
			}
		}
	}

	fmt.Println(count)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	as := make([]*aElem, n)
	for i := 0; i < n; i++ {
		as[i] = &aElem{i, sc.ReadInt(), false}
	}

	factorMap := make(map[int]*aElemList)
	for _, a := range as {
		factors := Factorize(a.value)
		for _, factor := range factors {
			if factorMap[factor] == nil {
				factorMap[factor] = newAElemList()
			}
			factorMap[factor].Add(a)
		}
	}

	for _, a := range as {
		factorMap[a.value].Each(func(elem *aElem) {
			if elem != a {
				elem.marked = true
			}
		})
	}

	count := 0
	for _, a := range as {
		if !a.marked {
			count++
		}
	}

	fmt.Println(count)
}

type aElem struct {
	index  int
	value  int
	marked bool
}

type aElemList struct {
	first *aElemListNode
	last  *aElemListNode
}

type aElemListNode struct {
	child *aElemListNode
	value *aElem
}

func newAElemList() *aElemList {
	root := aElemListNode{nil, nil}
	return &aElemList{&root, &root}
}

func (list *aElemList) Add(value *aElem) {
	node := aElemListNode{nil, value}
	list.last.child = &node
	list.last = &node
}

func (list *aElemList) Each(f func(value *aElem)) {
	cur := list.first
	for cur.child != nil {
		cur = cur.child
		f(cur.value)
	}
}

func Factorize(n int) []int {
	primeCounts := PrimeFactorize(n)
	primeLen := len(primeCounts)
	if primeLen == 0 {
		return []int{1}
	}

	factorsLen := 1
	for _, primeCount := range primeCounts {
		factorsLen *= primeCount.Count + 1
	}

	factors := make([]int, 0, factorsLen)
	usePrimeCounts := make([]int, primeLen)
	lastPrimeCount := primeCounts[primeLen-1].Count
	for usePrimeCounts[primeLen-1] <= lastPrimeCount {
		factor := 1
		for i, primeCount := range primeCounts {
			factor *= Pow(primeCount.Value, usePrimeCounts[i])
		}
		factors = append(factors, factor)

		usePrimeCounts[0]++
		// carry
		for i := 0; i < primeLen-1; i++ {
			if usePrimeCounts[i] > primeCounts[i].Count {
				usePrimeCounts[i] = 0
				usePrimeCounts[i+1]++
			} else {
				break
			}
		}
	}

	return factors
}

func PrimeFactorize(n int) []ElemCount {
	primeCounts := make([]ElemCount, 0)

	addCountIfExist := func(i int) {
		count := 0
		for n%i == 0 {
			count++
			n /= i
		}
		if count > 0 {
			primeCounts = append(primeCounts, ElemCount{i, count})
		}
	}

	addCountIfExist(2)
	addCountIfExist(3)

	flag := true
	for i := 5; n > 1 && i*i <= n; {
		addCountIfExist(i)

		if flag {
			i += 2
		} else {
			i += 4
		}
		flag = !flag
	}

	if n > 1 {
		primeCounts = append(primeCounts, ElemCount{n, 1})
	}

	return primeCounts
}

type ElemCount struct {
	Value int
	Count int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent: %d", exponent))
	}
	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout

	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	N := getNextInt(scanner)
	A := make([]int, N)

	for i := 0; i < N; i++ {
		A[i] = getNextInt(scanner)
	}

	MAX := 1000005
	dp := make([]int, MAX)
	for _, v := range A {
		if dp[v] != 0 {
			dp[v] = 2
			continue
		}
		for i := v; i < MAX; i += v {
			dp[i]++
		}
	}
	ans := 0
	for _, v := range A {
		if dp[v] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


package main

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

func main() {
	var N int
	fmt.Scan(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	A := make([]int, N)
	m := make(map[int]int)
	for i := range A {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
		m[A[i]]++
	}
	var keys []int
	for k := range m {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	MAX := 1000000
	flags := make([]bool, MAX+1)
	for i := range flags {
		flags[i] = true
	}
	sum := 0
	for _, k := range keys {
		c := m[k]
		if !flags[k] {
			continue
		}
		if c == 1 {
			sum++
		}
		for num := k; num <= MAX; num += k {
			flags[num] = false
		}
	}
	fmt.Println(sum)

}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	sta := make(map[int]int, a[len(a)-1]+1)
	for _, v := range a {
		for i := 1; i <= a[len(a)-1]; i++ {
			if i%v == 0 {
				sta[i]++
			}
		}
	}

	ans := 0
	for _, v := range a {
		if sta[v] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	arr := scanNums(1)
	N := arr[0]
	As := scanNums(N)
	if N == 0 {
		fmt.Print(0)
		return
	}
	MySort(As)
	max := As[len(As)-1]
	dpTable := make([]int, max+1)
	prev := 0
	for _, el := range As {
		dpTable[el]++
		if prev == el {
			continue
		}
		if dpTable[el] > 0 {
			continue
		}
		for i := 2 * el; i <= max; el += el {
			dpTable[i]++
		}
	}
	count := 0
	for _, el := range As {
		if dpTable[el] == 1 {
			count++
		}
	}
	fmt.Print(count)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	arr := scanNums(1)
	N := arr[0]
	As := scanNums(N)
	MySort(As)
	stack := []int{}
	index := 0
	if len(As) == 0 {
		fmt.Print(0)
		return
	}
	db := 0
	for {
		if index >= len(As) {
			break
		}
		primer := As[index]
		stack = As[:index+1]
		tmp := 0
		if index+1 <= len(As) && As[index+1] == primer {
			db++
		}
		for i := index + 1; i < len(As); i++ {
			if As[i]%primer != 0 {
				stack = append(stack, As[i])
				continue
			}
		}
		As = stack
		if index >= 1 && primer*As[index-1] > As[len(As)-1] {
			break
		}
		if tmp > 0 {
			tmp--
		}
		index = index + tmp + 1
	}
	fmt.Print(len(As) - db)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	n := nextInt64()
	a := make([]int64, n)
	for i := int64(0); i < n; i++ {
		a[i] = nextInt64()
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] < a[j]
	})
	sum := 1
	if a[0] == a[1] {
		sum--
	}
	for i := int64(1); i < n; i++ {
		canDivide := false
		for j := int64(0); j < i; j++ {
			if a[i]%a[j] == 0 {
				canDivide = true
				break
			}
		}
		if !canDivide {
			sum++
		}
	}
	fmt.Println(sum)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	a_lis := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		a_lis[i] = a
	}

	cnt := make([]int, 1e6+5)
	for i := 0; i < N; i++ {
		x := a_lis[i]
		if cnt[x] != 0 {
			cnt[x] = 2
			continue
		}
		for j := x; j < len(cnt); j += x {
			cnt[j]++
		}
	}
	ans := 0
	for i := 0; i < N; i++ {
		if cnt[a_lis[i]] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}
	sort.Sort(SortBy(A))
	//fmt.Println(A)

	maxA := A[len(A)-1]
	//trueで初期化
	//dp[i]=falseのとき、iより小さいiの約数が、Aに存在しない
	dp := make([]bool, maxA+1)
	ans := 0
	for i := 0; i < N-1; i++ {
		if dp[A[i]] == true {
			continue
		}
		for j := 1; j <= maxA/A[i]; j++ {
			dp[j*A[i]] = true
		}
		if A[i] != A[i+1] {
			ans++
		}

	}

	if dp[maxA] == false {
		ans++
	}

	fmt.Println(ans)

}

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var mod = 1000000007

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &as[i])
	}
	sort.Ints(as)

	mx := as[n-1]
	nums := make([]int, mx+1)

	for _, v := range as {
		for j := v; j <= mx; j = j + v {
			nums[j]++
		}
	}

	ans := 0
	for _, v := range as {
		if nums[v] == 1 {
			ans++
		}
	}

	fmt.Println(ans)

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modinv(n, mod int) int {
	return modpow(n, mod-2, mod)
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Combination ...
type Combination struct {
	facts, invs []int
	mod         int
}

// NewCombination ...
func NewCombination(n, mod int) Combination {
	return Combination{
		facts: make([]int, n+1),
		invs:  make([]int, n+1),
		mod:   mod,
	}
}

func (cmb *Combination) calc(n, k int) int {
	ret := cmb.facts[n] * cmb.invs[k]
	ret %= cmb.mod
	ret = ret * cmb.invs[n-k]
	ret %= cmb.mod
	return ret
}

func (cmb *Combination) init(n int) {
	cmb.facts[0] = 1
	// 階乗を算出
	for i := 1; i <= n; i++ {
		cmb.facts[i] = cmb.facts[i-1] * i % cmb.mod
	}
	// 逆元を算出
	cmb.invs[n] = modinv(cmb.facts[n], cmb.mod)
	for i := n - 1; i >= 0; i-- {
		cmb.invs[i] = cmb.invs[i+1] * (i + 1) % cmb.mod
	}
}

// Utility
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

func pow(a, n int) int {
	ret := 1
	for i := 1; i <= n; i++ {
		ret *= a
	}
	return ret
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}

// priority_queue
type intHeap []int

func (h intHeap) Len() int           { return len(h) }
func (h intHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h intHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}
func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

// sortable points
type point struct {
	x int
	y int
}

type points []point

func (p points) Len() int {
	return len(p)
}

func (p points) Less(i, j int) bool {
	return p[i].x < p[j].x
}

func (p points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	a := make([]int, n)
	var au []int
	var ad []int
	for i := 0; i < n; i++ {
		ai := nextInt()
		if !contain(au, ai) {
			au = append(au, ai)
		} else {
			ad = append(ad, ai)
		}
		a[i] = ai
	}
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
	sort.Slice(au, func(i, j int) bool { return au[i] < au[j] })

	max := au[len(au)-1]
	sieve := make([]bool, max)

	for k, _ := range sieve {
		sieve[k] = true
	}

	for _, a := range au {
		sieve = knit(sieve, a, max)
	}

	r := 0
	for _, ai := range a {
		if contain(ad, ai) {
			continue
		}
		if sieve[ai-1] == false {
			continue
		}
		r++
	}

	fmt.Println(r)
}

func knit(sieve []bool, n int, max int) []bool {
	i := 2
	t := n * 2
	for t < max {
		if sieve[t-1] == false {
			return sieve
		}
		sieve[t-1] = false
		i++
		t = n * i
	}

	return sieve
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func contain(h []int, n int) bool {
	for _, v := range h {
		if n == v {
			return true
		}
	}
	return false
}


package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	a := scanInts(n)
	answer := notDivisible(n, a)
	fmt.Println(answer)
}

func debug(a ...interface{}) {
	// fmt.Println(a...)
}

func notDivisible(n int, a []int) int {
	sort.Ints(a)
	prev := -1
	maxA := a[n-1]
	divisors := make([]int, maxA+1)
	for i := 0; i < n; i++ {
		if prev == a[i] {
			continue
		}
		for j := 1; a[i]*j <= maxA; j++ {
			divisors[a[i]*j]++
		}
	}
	debug(divisors)
	count := 0
	for i := 0; i < n; i++ {
		if divisors[a[i]] == 1 {
			count++
		}
	}
	return count
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


// ソートすると、自分より小さいやつだけが対象となる
// 自分iを割り切るjがいたとき、jはiの約数のどれかである
// エラトステネス的に考えると、min(A)~max(A)までのすべてをA[i]の倍数で埋めていく感じになる？
// 1を含む場合・同じのを複数含む場合みたいな探索上しんどそうなやつは省く（ほかなんかある？）
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N := nextInt()
	preA := nextInts(N)
	Distinct := make(map[int]bool)
	A := []int{}
	T := make([]bool, int(1e6+1))
	sort.Ints(A)
	for _, a := range preA {
		if !Distinct[a] {
			Distinct[a] = true
			A = append(A, a)
		} else {
			// 同じのがあったらそれは駄目
			T[a] = true
		}
	}
	if A[0] == 1 {
		fmt.Println(1)
		return
	}
	for _, a := range A {
		for x := a * 2; x <= int(1e6+1); x += a {
			T[x] = true
		}
	}
	ans := 0
	for _, a := range A {
		if T[a] == false {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i:= 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	m := int(1e6+10)
	cnt := make([]int, m)
	for _,x := range a {
		if cnt[x] != 0 {
			cnt[x] = 2
			continue
		}
		for i := x; i <m; i += x {
			cnt[i]++
		}
	}
	ans := 0
	for _,x := range a {
		if cnt[x] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
	// "regexp"
)

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
	di8     = []int64{-1, -1, 0, 1, 1, 1, 0, -1}
	dj8     = []int64{0, -1, -1, -1, 0, 1, 1, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	N := readInt()
	A := make([]int64, N)
	for i := int64(0); i < N; i++ {
		A[i] = readInt()
	}
	var ans int64
	Int64s(A)
	d := solve(1e6, A)
	for i := 0; i < len(A); i++ {
		if d[A[i]] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}

/** エラトステネスの篩より解を求める。 計算量: O(n) */
func solve(N int64, numbers []int64) []int64 {
	data := make([]int64, N+1)
	data[0] = 0

	for pointer := 0; pointer < len(numbers); pointer++ {
		m := numbers[pointer]
		if data[m] != 0 {
			data[m] = 2
			continue
		}
		for i := m; i <= N; i += m {
			data[i]++
		}
	}
	return data
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


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
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	as := make([]*aElem, n)
	for i := 0; i < n; i++ {
		as[i] = &aElem{i, sc.ReadInt(), false}
	}

	factorMap := make(map[int]*aElemList)
	for _, a := range as {
		factors := Factorize(a.value)
		for _, factor := range factors {
			if factorMap[factor] == nil {
				factorMap[factor] = newAElemList()
			}
			factorMap[factor].Add(a)
		}
	}

	for _, a := range as {
		factorMap[a.value].Each(func(elem *aElem) {
			if elem != a {
				elem.marked = true
			}
		})
	}

	count := 0
	for _, a := range as {
		if !a.marked {
			count++
		}
	}

	fmt.Println(count)
}

type aElem struct {
	index  int
	value  int
	marked bool
}

type aElemList struct {
	first *aElemListNode
	last  *aElemListNode
}

type aElemListNode struct {
	child *aElemListNode
	value *aElem
}

func newAElemList() *aElemList {
	root := aElemListNode{nil, nil}
	return &aElemList{&root, &root}
}

func (list *aElemList) Add(value *aElem) {
	node := aElemListNode{nil, value}
	list.last.child = &node
	list.last = &node
}

func (list *aElemList) Each(f func(value *aElem)) {
	cur := list.first
	for cur.child != nil {
		cur = cur.child
		f(cur.value)
	}
}

func Factorize(n int) []int {
	primeCounts := PrimeFactorize(n)

	primeLen := len(primeCounts)
	primes := make([]int, primeLen)
	{
		i := 0
		for prime := range primeCounts {
			primes[i] = prime
			i++
		}
	}
	sort.Ints(primes)

	factorsLen := 1
	for _, count := range primeCounts {
		factorsLen *= count + 1
	}

	factors := make([]int, 0, factorsLen)
	usePrimeCounts := make([]int, primeLen)
	lastPrimeCount := primeCounts[primes[primeLen-1]]
	for usePrimeCounts[primeLen-1] <= lastPrimeCount {
		factor := 1
		for i, prime := range primes {
			usePrimeCount := usePrimeCounts[i]
			for j := 0; j < usePrimeCount; j++ {
				factor *= prime
			}
		}
		factors = append(factors, factor)

		usePrimeCounts[0]++
		// carry
		for i := 0; i < primeLen-1; i++ {
			prime := primes[i]
			primeCount := primeCounts[prime]
			if usePrimeCounts[i] > primeCount {
				usePrimeCounts[i] = 0
				usePrimeCounts[i+1]++
			} else {
				break
			}
		}
	}

	// TODO: sort
	return factors
}

func PrimeFactorize(n int) map[int]int {
	primeCounts := make(map[int]int)

	sqrtMax := int(math.Sqrt(float64(n)))

	for n%2 == 0 {
		primeCounts[2]++
		n /= 2
	}
	for n%3 == 0 {
		primeCounts[3]++
		n /= 3
	}

	flag := true
	for i := 5; n > 1 && i <= sqrtMax; {
		for n%i == 0 {
			primeCounts[i]++
			n /= i
		}

		if flag {
			i += 2
		} else {
			i += 4
		}
		flag = !flag
	}

	if n > 1 {
		primeCounts[n]++
	}

	return primeCounts
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        c := 0
        for i := range a {
                for j := range a {
                        if j > 1e3 {
                                break
                        }
                        if i != j {
                                if a[i]%a[j] == 0 {
                                        c++
                                        break
                                }
                        }
                }
        }
        return n - c
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
	// "regexp"
)

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
	di8     = []int64{-1, -1, 0, 1, 1, 1, 0, -1}
	dj8     = []int64{0, -1, -1, -1, 0, 1, 1, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	N := readInt()
	A := make([]int64, N)
	var B []int64
	m := make(map[int64]int64, N)
	for i := int64(0); i < N; i++ {
		A[i] = readInt()
		m[A[i]]++
	}
	var ans = N
	for k, v := range m {
		B = append(B, k)
		if v > 1 {
			ans = N - v
		}
	}
	Int64s(B)
	d := solve(10e6, B)
	for i := 0; i < len(B); i++ {
		if d[B[i]] >= 1 {
			ans--
		}
	}
	fmt.Println(ans)
}

/** エラトステネスの篩より解を求める。 計算量: O(n) */
func solve(N int64, numbers []int64) []int64 {
	data := make([]int64, N+1)
	data[0] = 0

	// logic
	pointer := 0
	for pointer < len(numbers) {
		m := numbers[pointer]
		for i := m * 2; i <= N; i += m {
			data[i]++
		}
		pointer++
	}
	return data
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	as := make([]*aElem, n)
	for i := 0; i < n; i++ {
		as[i] = &aElem{i, sc.ReadInt(), false}
	}

	factorMap := make(map[int]*aElemList)
	for _, a := range as {
		factors := Factorize(a.value)
		for _, factor := range factors {
			if factorMap[factor] == nil {
				factorMap[factor] = newAElemList()
			}
			factorMap[factor].Add(a)
		}
	}

	for _, a := range as {
		factorMap[a.value].Each(func(elem *aElem) {
			if elem != a {
				elem.marked = true
			}
		})
	}

	count := 0
	for _, a := range as {
		if !a.marked {
			count++
		}
	}

	fmt.Println(count)
}

type aElem struct {
	index  int
	value  int
	marked bool
}

type aElemList struct {
	first *aElemListNode
	last  *aElemListNode
}

type aElemListNode struct {
	child *aElemListNode
	value *aElem
}

func newAElemList() *aElemList {
	root := aElemListNode{nil, nil}
	return &aElemList{&root, &root}
}

func (list *aElemList) Add(value *aElem) {
	node := aElemListNode{nil, value}
	list.last.child = &node
	list.last = &node
}

func (list *aElemList) Each(f func(value *aElem)) {
	cur := list.first
	for cur.child != nil {
		cur = cur.child
		f(cur.value)
	}
}

func Cartesian(optionArrays [][]int) [][]int {
	optionArrayCount := len(optionArrays)

	productLen := 1
	for _, optionArray := range optionArrays {
		productLen *= len(optionArray)
	}

	product := make([][]int, 0, productLen)
	optionArrayIndexes := make([]int, optionArrayCount)
	for optionArrayIndexes[0] < len(optionArrays[0]) {
		variation := make([]int, optionArrayCount)
		for i, optionArray := range optionArrays {
			optionArrayIndex := optionArrayIndexes[i]
			variation[i] = optionArray[optionArrayIndex]
		}
		product = append(product, variation)

		optionArrayIndexes[optionArrayCount-1]++
		for i := optionArrayCount - 1; i > 0; i-- {
			if optionArrayIndexes[i] >= len(optionArrays[i]) {
				optionArrayIndexes[i] = 0
				optionArrayIndexes[i-1]++
			} else {
				break
			}
		}
	}

	return product
}

func Factorize(n int) []int {
	primeCounts := PrimeFactorize(n)

	primeMultiples := make([][]int, len(primeCounts))
	{
		index := 0
		for prime, count := range primeCounts {
			multiples := make([]int, count+1)
			multiples[0] = 1
			for i := 1; i < count+1; i++ {
				multiples[i] = multiples[i-1] * prime
			}
			primeMultiples[index] = multiples
			index++
		}
	}

	variations := Cartesian(primeMultiples)

	factors := make([]int, len(variations))
	for i, variation := range variations {
		product := 1
		for _, num := range variation {
			product *= num
		}
		factors[i] = product
	}
	// TODO: sort
	return factors
}

func PrimeFactorize(n int) map[int]int {
	primeCounts := make(map[int]int)

	sqrtMax := int(math.Sqrt(float64(n)))

	for n%2 == 0 {
		primeCounts[2]++
		n /= 2
	}
	for n%3 == 0 {
		primeCounts[3]++
		n /= 3
	}

	flag := true
	for i := 5; n > 1 && i <= sqrtMax; {
		for n%i == 0 {
			primeCounts[i]++
			n /= i
		}

		if flag {
			i += 2
		} else {
			i += 4
		}
		flag = !flag
	}

	if n > 1 {
		primeCounts[n]++
	}

	return primeCounts
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


package main

import (
	"fmt"
	"sort"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := make([]int, 0, n)
	m := map[int]int{}

	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		m[tmp]++
		if (m[tmp] <= 2) {
			a = append(a, tmp)
		}
	}
	sort.Ints(a)
	// fmt.Printf("%v\n", a)

	count := 0
	for i := 0; i < len(a); i++ {
		flag := true
		sqrt := int(math.Sqrt(float64(a[i])))
		for j := 0; j < len(a); j++ {
			if (i == j) {
				continue
			}
			if (a[j] > sqrt + 1) {
				break
			}
			if ((a[i] % a[j]) == 0) {
				flag = false
				break
			}
		}
		// 自分の前後の要素が重複要素かもしれない
		if (i > 0) && (a[i] % a[i-1]) == 0 {
			flag = false
		}
		if (i < len(a) -1) && (a[i] % a[i+1]) == 0 {
			flag = false
		}
		if (flag) {
			count++
		}
	}

	fmt.Printf("%d", count)
}


package main

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

func enumDivisors(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if n/i != i {
				res = append(res, n/i)
			}
		}
	}
	return
}
func lib_CountInt(values []int) map[int]int {
	m := map[int]int{}
	for _, value := range values {
		m[value]++
	}
	return m
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		A[i], _ = strconv.Atoi(scanner.Text())
	}
	fmt.Println(solve(N, A))
}
func solve(N int, A []int) (cnt int) {
	sort.Ints(A)
	aCounts := lib_CountInt(A)
	for _, a := range A {
		if aCounts[a] != 1 {
			continue
		}
		valid := true
		for _, e := range enumDivisors(a) {
			if _, ok := aCounts[e]; ok && e != a {
				valid = false
				break
			}
		}
		if valid {
			cnt++
		}
	}
	return
}


package main

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

func main() {
	var in []int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	inst := strings.Split(sc.Text(), " ")
	for _, i := range inst {
		t, _ := strconv.Atoi(i)
		in = append(in, t)
	}
	an, ok := 0, 0

	for j, i := range in {
		for k, l := range in {
			if j != k {
				if i%l == 0 {
					an++
					ok++
					break
				}
			}
			if ok == 1 {
				ok--
				break
			}
		}

	}

	fmt.Println(n - an)
}


package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	sort.Ints(a)
	flags := make(map[int]bool)
	dup := make(map[int]bool)
	ok := make(map[int]bool)
	for _, v := range a {
		flag := true
		for i := 1; i*i <= v; i++ {
			if v%i == 0 {
				if flags[i] {
					flag = false
				}
				if i*i != v {
					if flags[v/i] {
						flag = false
					}
				}
			}
		}
		if ok[v] {
			dup[v] = true
		}
		if flag && !flags[v] {
			ok[v] = true
		}
		flags[v] = true
	}
	fmt.Println(len(ok) - len(dup))
}


package main

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

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

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	//B := make([][]int64, N)
	var i int64 = 0
	var j int64 = 0
	var cnt int64 = 0
	var max int64 = 0

	for _, val := range A {
		if val > max {
			max = val
		}
	}

	/*
		//arr := make([]bool, int(math.Sqrt(float64(max)))+1)
		arr := make([]bool, int((float64(max)))+1)
		// 初期化
		// 素数を求める(falseが素数)
		arr[0] = true
		arr[1] = true
		for i := 2; i < len(arr); i++ {
			if arr[i] {
				for j := i * 2; j < len(arr); j += i {
					arr[j] = true
				}
			}
		}*/

	/*
		for i = 0; i< N ; i++ {
			B[i] = make([]int64, N)
		}
	*/

	for i = 0; i < N; i++ {
		flag := true
		flag2 := true
		for j = 0; j < N; j++ {
			if i == j {
				continue
			}
			if A[i] == A[j] {
				flag2 = false
				break
			}
			if A[j] == 1 {
				flag = false
				break
			}
		}
		if !flag2 {
			continue
		}
		if !flag {
			cnt++
			continue
		}
		/*
			if arr[A[i]] == false {
				cnt++
				continue
			}
		*/
		flag = true
		for j = 0; j < N; j++ {
			if i == j {
				continue
			}
			if A[i]%A[j] == 0 {
				flag = false
				break
			}
		}
		if flag {
			cnt++
		}
	}

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

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)
}


package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	sort.Ints(a)

	cnt := 0
	for i := 0; i < n; i++ {
		s := 0
		for j := 0; j < n && a[i] >= a[j]; j++ {
			if i != j {
				if a[i]%a[j] == 0 {
					s++
					break
				}
			}
		}
		if s == 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


package main

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

func main() {
	var n int
	var at []string
	var a []int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		at = strings.Split(sc.Text(), " ")
	}

	for _, e := range at {
		num, _ := strconv.Atoi(e)
		a = append(a, num)
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	var count int

	if a[n-1] != a[n-2] {
		count = 1
	} else {
		count = 0
	}

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			if a[i] == 0 || a[j] == 0 {
				break
			}
			if a[i]%a[j] == 0 {
				break
			}
			if i != 0 && a[i] == a[i-1] {
				break
			}
			if j == n-1 {
				count += 1
			}
		}
	}

	fmt.Print(count)

}


package main

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

var (
	finv, inv, fac [MAX]int
)

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func init() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
	//sc.Split(bufio.ScanLines)
	sc.Split(bufio.ScanWords)
	//sc.Buffer([]byte{}, 200100)
}

const (
	MOD = 1000000007
	MAX = 510000
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func IsPrime(num int) bool {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) bool {
	if pnum*pnum > num {
		if num != 1 {
			if result[num] > 0 {
				return false
			}

		}
		return true
	}

	if num%pnum == 0 {
		num /= pnum
		if result[pnum] > 0 {
			return false
		}
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

type UnionFind struct {
	par  []int
	size []int
}

func NewUnionFind(size int) *UnionFind {
	return new(UnionFind).init(size)
}

func (uf *UnionFind) init(size int) *UnionFind {
	uf.par = make([]int, size)
	uf.size = make([]int, size)

	for i := 0; i < size; i++ {
		uf.par[i] = i
		uf.size[i] = 1
	}
	return uf
}

func (uf *UnionFind) Unite(p int, q int) {
	rp := uf.Root(p)
	rq := uf.Root(q)
	if rp == rq {
		return
	}
	if uf.size[rp] < uf.size[rq] {
		uf.par[rp] = uf.par[rq]
		uf.size[rq] += uf.size[rp]
	} else {
		uf.par[rq] = uf.par[rp]
		uf.size[rp] += uf.size[rq]
	}
}

func (uf *UnionFind) Root(p int) int {
	for uf.par[p] == p {
		return p
	}
	uf.par[p] = uf.Root(uf.par[p])
	return uf.par[p]
}

func (uf *UnionFind) Size(p int) int {
	return uf.size[uf.Root(p)]
}

func (uf *UnionFind) Same(p int, q int) bool {
	return uf.Root(p) == uf.Root(q)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	n, _ := strconv.Atoi(getStr())
	return n
}

func getStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	N := getInt()
	A := make([]int, N)
	m := map[int]int{}
	for i := 0; i < N; i++ {
		A[i] = getInt()
		m[A[i]]++
	}
	//fmt.Println(m)
	if m[1] > 0 {
		if m[1] == 1 {
			fmt.Println(1)
			return
		} else {
			fmt.Println(0)
			return
		}
	}
	sort.Ints(A)
	cnt := 0
	max := A[N-1]
	filled := map[int]bool{}
	for i := 0; i < N; i++ {
		a := A[i]
		if filled[a] {
			continue
		}
		//fmt.Println(a, filled)
		if m[a] == 1 {
			cnt++
		}
		if a == 1 {
			filled[a] = true
		} else {
			v := a
			filled[a] = true
			for v <= max {
				v += a
				filled[v] = true
			}
		}
	}

	fmt.Println(cnt)
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	pl := make([]int, n)
	var p int
	for i := 0; i < n; i++ {
		fmt.Scan(&p)
		pl[i] = p
	}

	count := 0
	for i := 0; i < n; i++ {
		flag := true
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			if pl[i]%pl[j] == 0 {
				flag = false
				continue
			}
		}
		if flag {
			count++
		}
	}
	fmt.Println(count)
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n  int
	fmt.Scan(&n)

	a := make([]int, n)
	for i:= 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	counter := 0
	for i :=n-1; 0 <= i; i-- {
		for j :=0; j < n-1; j++ {
			if a[i] == a[j] {
				continue
			}
			if a[i] % a[j] == 0 {
				counter++
				break
			}
		}
	}
	if counter == 0 {
		fmt.Println(counter)
		return
	}
	fmt.Println(n-counter)

}


package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	cnt := map[int]int{}
	for i := 0; i < n; i++ {
		cnt[a[i]]++
	}

	ans := 0

	for i := 0; i < n; i++ {
		f := true
		if cnt[1] != 0 {
			f = false
		}
		if cnt[a[i]] != 1 {
			f = false
		}
		for j := 2; j*j <= a[i]; j++ {
			if a[i]%j == 0 {
				if cnt[a[i]/j] != 0 {
					f = false
				}
				if cnt[j] != 0 {
					f = false
				}
			}
		}
		if f {
			ans++
		}
	}

	fmt.Fprintln(wr, ans)
}


package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	m := make(map[int]bool)
	dup := make(map[int]bool)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		if _, ok := m[as[i]]; ok {
			dup[as[i]] = true
		}
		m[as[i]] = true
	}
	sort.Sort(sort.IntSlice(as))
	var sum int
	ms := make([]int, 1e6+1)
	for i := range as {
		num := as[i]
		if ms[num] == 1 {
			continue
		}
		if _, ok := dup[as[i]]; !ok {
			sum++
		}
		for j := num; j <= 1e6; j += num {
			ms[j] = 1
		}
	}
	fmt.Println(sum)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := scanLongIntSlices(1, 10000000)
	nums := lines[0]

	for _, n := range nums {
		if n == 0 {
			fmt.Println("0")
			os.Exit(0)
		}
	}

	prod := 1
	for _, n := range nums {
		if n > 1000000000000000000/prod {
			fmt.Println("-1")
			os.Exit(0)
		}
		prod *= n
	}

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

func scanLongIntSlices(lines int, maxBufSize int) ([][]int, error) {

	res := [][]int{}

	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, bufio.MaxScanTokenSize)
	sc.Buffer(buf, maxBufSize)

	for sc.Scan() {
		line := sc.Text()
		strs := strings.Split(line, " ")
		ints := make([]int, len(strs))
		for i, c := range strs {
			n, err := strconv.Atoi(c)
			if err != nil {
				return nil, err
			}
			ints[i] = n
		}
		res = append(res, ints)
	}

	if err := sc.Err(); err != nil {
		return nil, err
	}

	return res, nil
}

Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0


package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	lines, _ := scanLongIntSlices(1, 10000000)
	nums := lines[0]

	prod := big.NewInt(1)
	for _, n := range nums {
		prod.Mul(prod, big.NewInt(int64(n)))
	}
	if prod.Cmp(big.NewInt(1000000000000000000)) > 0 {
		fmt.Println("-1")
	} else {
		fmt.Printf("%s\n", prod.String())
	}
}

func scanLongIntSlices(lines int, maxBufSize int) ([][]int, error) {

	res := [][]int{}

	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, bufio.MaxScanTokenSize)
	sc.Buffer(buf, maxBufSize)

	for sc.Scan() {
		line := sc.Text()
		strs := strings.Split(line, " ")
		ints := make([]int, len(strs))
		for i, c := range strs {
			n, err := strconv.Atoi(c)
			if err != nil {
				return nil, err
			}
			ints[i] = n
		}
		res = append(res, ints)
	}

	if err := sc.Err(); err != nil {
		return nil, err
	}

	return res, nil
}


package main

import (
	"fmt"
)

func main() {
	var (
		n int
	)

	fmt.Scan(&n)
	max := 1000000000000000000
	a := make([]int, n)
	sum := 1
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			fmt.Print(0)
			return
		}
	}
	for _, j := range a {
		if j <= max/sum {
			sum *= j
		} else {
			fmt.Print(-1)
			return
		}
	}
	fmt.Print(sum)
}


package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	for i := 0; i < n; i++ {
		if aa[i] == 0 {
			fmt.Fprintln(writer, 0)
			return
		}
	}
	var ans int64 = 1
	for i := 0; i < n; i++ {
		if int64(1e18)/aa[i] < ans {
			fmt.Fprintln(writer, -1)
			return
		}
		ans *= aa[i]
	}
	fmt.Fprintln(writer, ans)
}


package main

import "fmt"

func main() {
	var N int
  fmt.Scan(&N)
  nums := make([]int, N)
  for i := range nums{
    fmt.Scan(&nums[i])
  }
  ok := true
  ans := 1
  for _, num := range nums{
  	ans = ans * num
    if ans > 1000000000000000000{
      ok = false
    }
  }
  if ok == true {
    fmt.Println(ans)
  }else{
    fmt.Println(-1)
  }
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	arr := make([]int, n)

	ans := 1
	for i := range arr {
		num := scanInt()
		if num == 0 {
			ans = 0
		}
		arr[i] = num
	}

	if ans != 0 {
		for _, e := range arr {
			if ans > 1e18/e {
				ans = -1
				break
			}

			ans *= e
		}
	}

	fmt.Println(ans)
}


package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	a:=make([]int,n)
	sum:=1
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i]!=0 && int(math.Pow(10.0, 18.0))/a[i] <sum {
			fmt.Println(-1)
			return
		}
		sum *= a[i]
	}
	fmt.Println(sum)

}


package main

import "fmt"
import "strconv"

func main() {
        var n int
        fmt.Scan(&n)
        var ans = 1
        var upper = 1000000000000000000
        for i := 0; i < n; i++ {
                var tmp int
                fmt.Scan(&tmp)
                if tmp == 0 {
                        ans = 0
                        break
                }
                if ans == -1 {
                        continue
                }
                var a = strconv.Itoa(tmp)
                var b = strconv.Itoa(ans)
                if len(a)+len(b) > 18 {
                        ans = -1
                        continue
                }
                ans *= tmp
                if ans > upper {
                        ans = -1
                }

        }
        fmt.Print(ans)
}


package main

import (
	"bufio"
	"fmt"
	// "math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

const max = 1000000000000000000
func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	n := nextInt()
	num := 1
	for i := 0; i < n; i++ {
		num *= nextInt()
		if num > max {
			break
		}
	}
	if num <= max {
		fmt.Println(num)
	} else {
		fmt.Println(-1)
	}
}


package main
import (
    "bufio"
    "fmt"
    "math/big"
    "os"
    "strconv"
    "strings"
)

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

func main() {
    N := getStdinInt()
    A := getStdinIntArr64()
    Abig := make([]*big.Int, N)
    for i := 0; i < N; i++ {
        Abig[i] = big.NewInt(A[i])
    }

    for i := range A {
        if A[i] == 0 {
            fmt.Println(0)
            return
        }
        if A[i] > 1000000000000000000 {
            fmt.Println(-1)
            return
        }
    }

    ans := big.NewInt(1)
    cmp := big.NewInt(1000000000000000000)

    for i := range Abig {
        ans = ans.Mul(ans, Abig[i])
        if ans.Cmp(cmp) == 1 {
            fmt.Println(-1)
            return
        }
    }

    fmt.Println(ans)
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinintArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinIntArr64() []int64 {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int64, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.ParseInt(v, 10, 64)
    }
    return res
}
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)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	ans := 1
	for _, num := range a {
		ans *= num
	}
	if float64(ans) > math.Pow(10.0, 18.0) {
		fmt.Println(-1)
		return
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"io"
	"math/big"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	n := sc.Int()
	a := sc.Int64s(n)

	for _, v := range a {
		if v == 0 {
			fmt.Println(0)
			return
		}
	}

	res := big.NewInt(1)
	max := big.NewInt(1000000000000000000)

	for _, v := range a {
		res = res.Mul(res, big.NewInt(v))
		if res.Cmp(max) == 1 {
			fmt.Println(-1)
			return
		}
	}

	fmt.Println(res)
}

// generated by https://github.com/murosan/gollect

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScanner(r io.Reader) *Scanner { return NewScannerSize(r, 4096) }
func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) Int() int     { return ParseInt(s.bytes()) }
func (s *Scanner) Int64() int64 { return ParseInt64(s.bytes()) }

func (s *Scanner) Int64s(len int) []int64 {
	a := make([]int64, len)
	for i := 0; i < len; i++ {
		a[i] = s.Int64()
	}
	return a
}

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}

func ParseInt64(b []byte) (n int64) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int64(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	n := sc.Int()

	res := sc.UInt64()
	for i := 1; i < n; i++ {
		res *= sc.UInt64()

		if res == 0 {
			fmt.Println(0)
			return
		}
		if res > 1000000000000000000 {
			fmt.Println(-1)
			return
		}
	}

	fmt.Println(res)
}

// generated by https://github.com/murosan/gollect

type Scanner struct {
	r     io.Reader
	buf   []byte
	delim byte
	size, eof,
	start, end int
}

func NewScanner(r io.Reader) *Scanner { return NewScannerSize(r, 4096) }
func NewScannerSize(r io.Reader, size int) *Scanner {
	return &Scanner{
		r:     r,
		buf:   make([]byte, size),
		delim: ' ',
		size:  size, start: size, end: size,
	}
}

func (s *Scanner) Int() int { return ParseInt(s.bytes()) }

func (s *Scanner) UInt64() uint64 { return ParseUInt64(s.bytes()) }

func (s *Scanner) bytes() []byte { b, _ := s.next(); return b }
func (s *Scanner) next() (b []byte, size int) {
	for n := 0; ; {
		for i := s.end; i < s.size; i++ {
			if s.buf[i] == s.delim || s.buf[i] == '\n' || i == s.eof {
				b, size = s.buf[s.start:i], i-s.start
				s.start, s.end = i+1, i+1
				return
			}
		}
		s.end = s.size
		if n++; n == 2 {
			panic("lack of buffer size")
		}
		s.read()
	}
}
func (s *Scanner) read() {
	copy(s.buf, s.buf[s.start:s.end])
	s.end -= s.start
	s.start = 0
	n, _ := s.r.Read(s.buf[s.end:])
	s.eof = s.end + n
}

func ParseInt(b []byte) (n int) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += int(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}

func ParseUInt64(b []byte) (n uint64) {
	var i int
	if b[0] == '-' {
		i++
	}
	for ; i < len(b); i++ {
		n *= 10
		n += uint64(b[i] - '0')
	}
	if b[0] == '-' {
		return -n
	}
	return
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	var (
		ans  int64 = 1
		a    int64
		over bool = false
		zero bool = false
	)

	for i := 0; i < n; i++ {
		fmt.Scan(&a)

		if a >= math.MaxInt64/ans {
			over = true
		}
		if a == 0 {
			zero = true
		}
		if !over && !zero {
			ans *= a
		}
		if ans > 1e18 {
			over = true
		}
	}

	if zero {
		fmt.Println(0)
	} else if over {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


package main

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

func main() {

	var n int64
	// //fmt.Println("n")
	fmt.Scanf("%d", &n)
	// //fmt.Println("input" + strconv.FormatInt(n, 10))
	// inputAarray := make([]uint64, 0, n)

	// for {
	//fmt.Println("A:" + strconv.FormatInt(count, 10))
	// 	fmt.Scanf("%d", &a)
	// 	//fmt.Println("input" + strconv.FormatInt(a, 10))
	// 	inputAarray = append(inputAarray, a)
	// 	count++
	// 	if count+1 > n {
	// 		break
	// 	}
	// }
	var instr string
	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		instr = sc.Text()
	}
	// fmt.Println("instrnum:" + instr)
	inarray := strings.Split(instr, " ")
	var vrslt int64
	vrslt = 1
	// fmt.Println("size:" + strconv.Itoa(len(inarray)))
	iszero := 1
	for _, v := range inarray {
		var a int64
		//fmt.Println("vrslt:" + strconv.FormatInt(vrslt, 10))
		a, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			// fmt.Println(err)
		}
		// fmt.Println("vrslt:" + strconv.FormatUint(vrslt, 10))
		if a == 0 {
			iszero = 0
			break
		}
		if vrslt > 1000000000000000000/a {
			vrslt = -1
		}
		vrslt = vrslt * a
	}

	if iszero == 0 {
		fmt.Printf("%d", 0)
	} else {
		fmt.Printf("%d", vrslt)
	}
}


package main

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

func main() {

	var n int64
	// //fmt.Println("n")
	fmt.Scanf("%d", &n)
	// //fmt.Println("input" + strconv.FormatInt(n, 10))
	// inputAarray := make([]uint64, 0, n)

	// for {
	//fmt.Println("A:" + strconv.FormatInt(count, 10))
	// 	fmt.Scanf("%d", &a)
	// 	//fmt.Println("input" + strconv.FormatInt(a, 10))
	// 	inputAarray = append(inputAarray, a)
	// 	count++
	// 	if count+1 > n {
	// 		break
	// 	}
	// }
	var instr string
	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		instr = sc.Text()
	}
	// fmt.Println("instrnum:" + instr)
	inarray := strings.Split(instr, " ")
	var vrslt int64
	vrslt = 1
	// fmt.Println("size:" + strconv.Itoa(len(inarray)))
	for _, v := range inarray {
		var a int64
		//fmt.Println("vrslt:" + strconv.FormatInt(vrslt, 10))
		a, err := strconv.ParseInt(v, 10, 64)
		if err != nil {
			// fmt.Println(err)
		}
		// fmt.Println("vrslt:" + strconv.FormatUint(vrslt, 10))
		if a == 0 {
			vrslt = 0
			break
		}
		if vrslt > 1000000000000000000/a {
			vrslt = -1
			break
		}
		vrslt = vrslt * a
	}

	if vrslt > 1000000000000000000 {
		fmt.Printf("%d", -1)
	} else {
		fmt.Printf("%d", vrslt)
	}
}


package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        var out int = 1

        for _, num := range a {
                if num == 0 {
                        return 0
                }
        }
        for _, num := range a {
                out *= num
                if 1 > 1e18/out {
                        return -1
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, 0, n)
        for i := 0; i < n; i++ {
                var t int
                fmt.Scan(&t)
                a = append(a, t)
        }
        fmt.Println(solution(n, a))
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

var DEBUG = true

func main() {
	defer Flush()
	_, A := readInts(0)

	for _, v := range A {
		if v == 0 {
			println(0)
			return
		}
	}

	ans := uint(1)
	for i := range A {
		v := uint(A[i])
		nans := ans * v
		if 1000000000000000000 < nans || nans < ans {
			println(-1)
			return
		}
		ans = nans
	}
	println(ans)

}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &nums[i])
	}

	total := 1
	for i := 0; i < n; i++ {
		if nums[i] == 0 {
			total = 0
			break
		}
	}

	if total == 0 {
		fmt.Println(total)
	} else {
		for i := 0; i < n; i++ {
			total = total * nums[i]
			if nums[i] > 1000000000000000000/total {
				total = -1
				break
			}
		}

		fmt.Println(total)
	}
}


package main

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

var limit uint64 = 1

func init() {
	for i := 0; i < 18; i++ {
		limit *= 10
	}
}

func main() {
	N := readlineint()[0]
	In := readlineint()

	for _, v := range In {
		if v == 0 {
			fmt.Println("0")
			return
		}
	}

	var previous_result uint64 = 1
	var result uint64 = 1
	for i := 0; i < N; i++ {
		previous_result = result
		result *= uint64(In[i])

		if result > limit || previous_result > result {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(result)
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {
	fmt.Printf(format+"\n", elements...)
}

var bufreader = bufio.NewReaderSize(os.Stdin, 1e6)

func readline() string {
	a, _, _ := bufreader.ReadLine()
	return string(a)
}

func readlineint() (result []int) {
	in := strings.Split(readline(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}