package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

var primeNumbers = []int{
	2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		exec()
	}
}

func exec() {
	var n int
	scanf("%d\n", &n)

	numbers, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	colors := make([]int, len(numbers))
	colorsByLCD := map[int]int{}
	maxColor := 0
NUMBERS:
	for i, number := range numbers {
		for _, prime := range primeNumbers {
			if number%prime == 0 {
				color, ok := colorsByLCD[prime]
				if !ok {
					maxColor++
					color = maxColor
					colorsByLCD[prime] = color
				}
				colors[i] = color
				continue NUMBERS
			}
		}
	}
	printf("%d\n", maxColor)
	printf("%d", colors[0])
	for i := 1; i < len(colors); i++ {
		printf(" %d", colors[i])
	}
	printf("\n")
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	ps := [...]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		c := map[int]int{}
		Fscan(in, &n)
		ans := make([]interface{}, n)
		for i := range ans {
			Fscan(in, &v)
			for _, p := range ps {
				if v%p == 0 {
					if c[p] == 0 {
						c[p] = len(c) + 1
					}
					ans[i] = c[p]
					break
				}
			}
		}
		Fprintln(out, len(c))
		Fprintln(out, ans...)
	}
}

func main() { CF1332B(os.Stdin, os.Stdout) }

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int64, []int64) {
    res := make([]int64, len(aa))
    for i := range aa {
        for _, p := range primes {
            if aa[i] % p == 0 {
                res[i] = p
                break
            }
        }
    }

    counter := int64(0)
    m := map[int64]int64{}
    for _, r := range res {
        if m[r] == 0 {
            counter++
            m[r] = counter
        }
    }
    for i := range res {
        res[i] = m[res[i]]
    }
    return counter, res
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	// var t int = 1
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1

	for _, prime := range primes[:11] {
		if list, ok := primeToIndex[prime]; ok {
			used := false
			for _, v := range list {
				if colored[v] == 0 {
					colored[v] = color
					used = true
				}
			}
			if used {
				color++
			}
		}
	}
	/*
		for i, v := range indexToPrimes {
			fmt.Printf("\t%d: %d: ", i, array[i])
			for _, vi := range v {
				fmt.Print(" ", vi)
			}
			fmt.Println()
		}

		for index := range array {
			if colored[index] == 0 {
				colorPath(index, color, indexToPrimes, primeToIndex, colored)
				color++
			}
		}
	*/
	fmt.Println(color - 1)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println(primes[:50])
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

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

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e == 1 {
			break
		}

		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 23
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{437, 519, 865, 808, 909, 391, 194, 291, 237, 395, 323, 365, 511, 497, 781, 737, 871, 559, 731, 697, 779, 841, 961}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
	0: 437:  19 23
	1: 519:  3 173
	2: 865:  5 173
	3: 808:  2 101
	4: 909:  3 101
	5: 391:  17 23
	6: 194:  2 97
	7: 291:  3 97
	8: 237:  3 79
	9: 395:  5 79
	10: 323:  17 19
	11: 365:  5 73
	12: 511:  7 73
	13: 497:  7 71
	14: 781:  11 71
	15: 737:  11 67
	16: 871:  13 67
	17: 559:  13 43
	18: 731:  17 43
	19: 697:  17 41
	20: 779:  19 41
	21: 841:  29
	22: 961:  31
*/

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	p := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	for t := in(); t > 0; t-- {
		n := in()
		a := make([]int, n)

		for i := range a {
			a[i] = in()
		}

		b := make([]int, n)

		cnt := 0

		for i := range p {
			okay := false
			for j := range a {
				if b[j] == 0 && a[j]%p[i] == 0 {
					b[j] = cnt + 1
					okay = true
				}
			}

			if okay {
				cnt++
			}
		}

		fmt.Println(cnt)

		for i := range b {
			fmt.Print(b[i], " ")
		}

		fmt.Println()
	}

}

/*
URL:
https://codeforces.com/problemset/problem/1332/B
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int

	P []int
)

func main() {
	_, P = sieve(50)

	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	B := make([]int, n)

	for i := 0; i < 11; i++ {
		p := P[i]

		for j := 0; j < n; j++ {
			if A[j]%p == 0 && B[j] == 0 {
				B[j] = i + 1
			}
		}
	}

	pressed, _, _ := ZaAtsu1Dim(B, 1)
	fmt.Println(Max(pressed...))
	fmt.Println(PrintIntsLine(pressed...))
}

// ZaAtsu1Dim returns 3 values.
// pressed: pressed slice of the original slice
// orgToPress: map for translating original value to pressed value
// pressToOrg: reverse resolution of orgToPress
// O(nlogn)
func ZaAtsu1Dim(org []int, initVal int) (pressed []int, orgToPress, pressToOrg map[int]int) {
	pressed = make([]int, len(org))
	copy(pressed, org)
	sort.Sort(sort.IntSlice(pressed))

	orgToPress = make(map[int]int)
	for i := 0; i < len(org); i++ {
		if i == 0 {
			orgToPress[pressed[0]] = initVal
			continue
		}

		if pressed[i-1] != pressed[i] {
			initVal++
			orgToPress[pressed[i]] = initVal
		}
	}

	for i := 0; i < len(org); i++ {
		pressed[i] = orgToPress[org[i]]
	}

	pressToOrg = make(map[int]int)
	for k, v := range orgToPress {
		pressToOrg[v] = k
	}

	return
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	// var t int = 1
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 0

	for _, prime := range primes[:11] {
		if list, ok := primeToIndex[prime]; ok {
			color++
			for _, v := range list {
				colored[v] = color
			}
		}
	}
	/*
		for i, v := range indexToPrimes {
			fmt.Printf("\t%d: %d: ", i, array[i])
			for _, vi := range v {
				fmt.Print(" ", vi)
			}
			fmt.Println()
		}

		for index := range array {
			if colored[index] == 0 {
				colorPath(index, color, indexToPrimes, primeToIndex, colored)
				color++
			}
		}
	*/
	fmt.Println(color)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println(primes[:50])
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

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

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e == 1 {
			break
		}

		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 23
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{437, 519, 865, 808, 909, 391, 194, 291, 237, 395, 323, 365, 511, 497, 781, 737, 871, 559, 731, 697, 779, 841, 961}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
	0: 437:  19 23
	1: 519:  3 173
	2: 865:  5 173
	3: 808:  2 101
	4: 909:  3 101
	5: 391:  17 23
	6: 194:  2 97
	7: 291:  3 97
	8: 237:  3 79
	9: 395:  5 79
	10: 323:  17 19
	11: 365:  5 73
	12: 511:  7 73
	13: 497:  7 71
	14: 781:  11 71
	15: 737:  11 67
	16: 871:  13 67
	17: 559:  13 43
	18: 731:  17 43
	19: 697:  17 41
	20: 779:  19 41
	21: 841:  29
	22: 961:  31
*/

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1
	for index := range array {
		if colored[index] == 0 {
			colorPath(index, color, indexToPrimes, primeToIndex, colored)
			color++
		}
	}

	fmt.Println(colored)

	// fmt.Println(indexToPrimes)
	// fmt.Println()
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 5
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{4, 6, 69, 25, 343}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1
	for index := range array {
		if colored[index] == 0 {
			colorPath(index, color, indexToPrimes, primeToIndex, colored)
			color++
		}
	}

	fmt.Println(color - 1)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println()
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 5
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{4, 6, 69, 25, 343}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
URL:
https://codeforces.com/problemset/problem/1332/B
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int

	P []int
)

func main() {
	_, P = sieve(50)

	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	B := make([]int, n)

	for i := 0; i < 11; i++ {
		p := P[i]

		for j := 0; j < n; j++ {
			if A[j]%p == 0 && B[j] == 0 {
				B[j] = i + 1
			}
		}
	}

	fmt.Println(Max(B...))
	fmt.Println(PrintIntsLine(B...))
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	p := [...]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		c := 0
		used := make([]bool, len(p))
		Fscan(in, &n)
		ans := make([]interface{}, n)
		for i := range ans {
			Fscan(in, &v)
			for j, pi := range p {
				if v%pi == 0 {
					if !used[j] {
						used[j] = true
						c++
					}
					ans[i] = c
					break
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

func main() { CF1332B(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := make([]interface{}, n)
		c := 0
		for i, x := range a {
			if ans[i] == nil {
				c++
				for j := i; j < n; j++ {
					if gcd(a[j], x) > 1 {
						ans[j] = c
					}
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

func main() { CF1332B(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := make([]interface{}, n)
		c := 0
		for i, x := range a {
			if ans[i] == nil {
				c++
				for j, y := range a {
					if gcd(x, y) > 1 {
						ans[j] = c
					}
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

func main() { CF1332B(os.Stdin, os.Stdout) }

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int, []int) {
    colors := map[int]bool{}
    res := make([]int, len(aa))
    for i := range aa {
        for pi, p := range primes {
            if aa[i] % p == 0 {
                colors[pi+1] = true
                res[i] = pi+1
                break
            }
        }
    }
    return len(colors), res
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int, []int) {
    colors := map[int]bool{}
    res := make([]int, len(aa))
    for i := range aa {
        for pi, p := range primes {
            if aa[i] % p == 0 {
                colors[pi+1] = true
                res[i] = pi+1
                break
            }
        }
    }
    return 11, res
}


package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) (is, js []int, flag bool) {
	flag = false

	for c := 1; c <= n; c++ {
		if i <= j*c+n {
			v := (n + j*c) / i
			d := (n + j*c) % i

			for cc := 0; cc < i; cc++ {
				vv := v
				if cc < d && d != 0 {
					vv += 1
				}
				is = append(is, vv)
			}

			for cc := 0; cc < j; cc++ {
				js = append(js, c)
			}

			if is[0] <= n {
				flag = true
			}
			break
		} else if j == 0 {
			break
		}
	}
	return
}

func bingo(s string, is, js []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i, j int = 0, 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteString(strconv.Itoa(js[j]))
					j++
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	//fmt.Println(i, j, n)
	is, js, flag := result(i, j, n)
	bingo(s, is, js, flag)

}

package main

import "fmt"

func main() {
	var q, op string
	var plus, minus, n int
	plus++
	ops := []string{"+"}
	for n == 0 {
		fmt.Scan(&q, &op)
		if op != "=" {
			ops = append(ops, op)
		}
		switch op {
		case "+":
			plus++
		case "-":
			minus++
		case "=":
			fmt.Scan(&n)
		default:
			panic(op)
		}
	}
	min := -n*minus + plus
	max := n*plus - minus
	if n < min || n > max {
		fmt.Println("Impossible")
		return
	}
	fmt.Println("Possible")
	cur := plus - minus
	for i := range ops {
		if i > 0 {
			fmt.Print(" " + ops[i] + " ")
		}
		num := 1
		switch {
		case cur < n:
			if ops[i] == "+" {
				add := n - cur
				if add > n-1 {
					add = n - 1
				}
				cur += add
				num += add
			}
		case cur > n:
			if ops[i] == "-" {
				sub := cur - n
				if sub > n-1 {
					sub = n - 1
				}
				cur -= sub
				num += sub
			}
		}
		fmt.Print(num)
	}
	fmt.Println(" = ", n)
}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, []int, bool) {
	var is, js []int

	flag := true
	if i <= j+n {
		v := (n + j) / i
		d := (n + j) % i

		for c := 0; c < i; c++ {
			if c < d && d != 0 {
				is = append(is, v+1)
			} else {
				is = append(is, v)
			}
		}

		for c := 0; c < j; c++ {
			js = append(js, 1)
		}

		if v <= 0 || is[0] > n {
			flag = false
		}
	} else {
		if j != 0 {
			for c := 0; c < i; c++ {
				is = append(is, 1)
			}

			v := (i - n - j) / j
			d := (i - n - j) % j
			for c := 0; c < j; c++ {
				if c < d && d != 0 {
					js = append(js, v+1+1)
				} else {
					js = append(js, v+1)
				}
			}

			if v+1 > n || v+2 > n {
				flag = false
			}
		} else {
			flag = false
		}
	}
	return is, js, flag
}

func bingo(s string, is, js []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i, j int = 0, 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteString(strconv.Itoa(js[j]))
					j++
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	//fmt.Println(i, j, n)
	is, js, flag := result(i, j, n)
	bingo(s, is, js, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		is = append(is, v)
	}
	is[0] += d

	if v <= 0 || v+d > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || v+1 > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d && d != 0 {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || v+1 > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d && d != 0 {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || is[0] > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

import "fmt"

func main() {
	var q, op string
	var plus, minus, n int
	plus++
	ops := []string{"+"}
	for n == 0 {
		fmt.Scan(&q, &op)
		if op != "=" {
			ops = append(ops, op)
		}
		switch op {
		case "+":
			plus++
		case "-":
			minus++
		case "=":
			fmt.Scan(&n)
		default:
			panic(op)
		}
	}
	min := -n*minus + plus
	max := n*plus - minus
	if n < min || n > max {
		fmt.Println("Impossible")
		return
	}
	fmt.Println("Possible")
	cur := plus - minus
	for i := range ops {
		if i > 0 {
			fmt.Print(" " + ops[i] + " ")
		}
		num := 1
		switch {
		case cur < n:
			if ops[i] == "+" {
				add := n - cur
				if add > n-1 {
					add = n - 1
				}
				cur += add
				num += add
			}
		case cur > n:
			if ops[i] == "-" {
				sub := cur - n
				if sub > n-1 {
					sub = n - 1
				}
				cur -= sub
				num -= sub
			}
		}
		fmt.Print(num)
	}
	fmt.Println(" = ", n)
}


package main

import (
	"fmt"
)

func main(){
	var n, m, ans int
	var data [105]int
	fmt.Scanf("%d %d\n", &n, &m)
	arr := data[0:n + 1]
	arr[0] = 0
	for i := 1; i <= n; i++{
		if i == n{
			fmt.Scanf("%d\n", &arr[i])
		}else{
			fmt.Scanf("%d", &arr[i])
		}
		arr[i] += arr[i - 1]
	}
	ans = 0
	for i := 0; i < m; i++{
		s, t := 0, 0
		fmt.Scanf("%d %d\n", &s, &t)
		if arr[t] - arr[s - 1] > 0{
			ans += arr[t] - arr[s - 1];
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
	sc := NewScanner()
	_, m := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()
	ans := 0
	for i := 0; i < m; i++ {
		L, R := sc.NextInt(), sc.NextInt()
		sm := 0
		for i := L - 1; i <= R - 1; i++ {
			sm += A[i]
		}
		if sm >= 0 {
			ans += sm
		}
	}
	fmt.Println(ans)

}

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func solve() {
    n, m := readInt(), readInt()
    a := readIntArray(n)
    ans := 0
    for t := 0; t < m; t++ {
        l, r := readInt()-1, readInt()-1
        s := 0
        for i := l; i <= r; i++ {
            s += a[i]
        }
        if s > 0 {
            ans += s
        }
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

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

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

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

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, c int
	fmt.Scan(&n, &c)
	raw := make([]int, n)
	sum := make([]int, n)
	values := make([]int, c)
	for i := 0; i < n; i++ {
		fmt.Scan(&raw[i])
		sum[i] = raw[i]
		if i > 0 {
			sum[i] += sum[i-1]
		}
	}
	for i := 0; i < c; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		left := 0
		if a > 0 {
			left = sum[a-1]
		}
		values[i] = (sum[b] - left)
	}
	sort.Ints(values)
	ans := 0
	for i := len(values) - 1; i >= 0; i-- {
		if values[i] < 0 {
			break
		}
		ans += values[i]
	}
	fmt.Println(ans)
}

package main

import "fmt"

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

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

	var sc []int
	for i := 0; i < m; i++ {
		var l, r, s int
		fmt.Scan(&l, &r)
		for j := l - 1; j < r && j < n; j++ {
			s += a[j]
		}
		sc = append(sc, s)
	}

	var res int
	for _, s := range sc {
		if s > 0 {
			res += s
		}
	}

	fmt.Println(res)
}


package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	ones := 0
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 1 {
			ones++
		}
	}
	var res []int
	if ones > 0 {
		for i := 0; i < ones; i++ {
			res = append(res, 1)
		}
		for _, j := range a {
			if j != 1 && !composite[j+1] {
				res = append(res, j)
				break
			}
		}
	}
	if len(res) == 0 {
		res = append(res, a[0])
	}
	if len(res) < 2 {
	Loop:
		for i, x := range a {
			for _, y := range a[i+1:] {
				if !composite[x+y] {
					res = []int{x, y}
					break Loop
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func isPrime(n int) bool {

	if n == 2 || n == 3 {
		return true
	} else if n == 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 6; (i-1)*(i-1) <= n; i += 6 {
		if n%(i-1) == 0 || n%(i+1) == 0 {
			return false
		}
	}

	return true
}

func main() {
	n, max := 0, 0
	fmt.Fscanf(stdin, "%d\n", &n)

	one, odd, even := make([]int, 0), make([]int, 0), make([]int, 0)
	for i := 0; i < n; i++ {
		number := 0
		fmt.Fscanf(stdin, "%d", &number)
		switch {
		case number == 1:
			one = append(one, 1)
		case number%2 == 0:
			even = append(even, number)
		case number%2 == 1:
			odd = append(odd, number)
		}
	}
	fmt.Fscanf(stdin, "\n", nil)

	/* Choose all 1 and select 1 even number */
	if len(one) > 0 && len(even) > 0 {
		for _, value := range even {
			if isPrime(value+1) == true {
				max = len(one) + 1
				fmt.Fprintf(stdout, "%d\n", max)
				for i := 0; i < len(one); i++ {
					fmt.Fprintf(stdout, "1 ")
				}
				fmt.Fprintf(stdout, "%d\n", value)
				stdout.Flush()
				return
			}
		}
	}

	if len(one) >= 2 {
		fmt.Fprintf(stdout, "%d\n", len(one))
		for i := 0; i < len(one); i++ {
			fmt.Fprintf(stdout, "1 ")
		}
		fmt.Fprintf(stdout, "\n")
		stdout.Flush()
		return
	}

	if len(odd) > 0 && len(even) > 0 {
		for i := 0; i < len(odd); i++ {
			for j := 0; j < len(even); j++ {
				if isPrime(odd[i]+even[j]) == true {
					fmt.Fprintf(stdout, "2\n%d %d\n", odd[i], even[j])
					stdout.Flush()
					return
				}
			}
		}
	}

	if len(one) > 0 {
		fmt.Fprintf(stdout, "1\n1\n")
		stdout.Flush()
		return
	}

	if len(odd) > 0 {
		fmt.Fprintf(stdout, "1\n%d\n", odd[0])
		stdout.Flush()
		return
	}

	if len(even) > 0 {
		fmt.Fprintf(stdout, "1\n%d\n", even[0])
		stdout.Flush()
		return
	}

	fmt.Fprintf(stdout, "0\n")

	stdout.Flush()
}

package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, 0, n)
	ones := 0
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scan(&ai)
		if ai == 1 {
			ones++
			continue
		}
		a = append(a, ai)
	}
	var res []int
	if ones > 0 {
		for i := 0; i < ones; i++ {
			res = append(res, 1)
		}
		for _, j := range a {
			if j == 2 {
				res = append(res, 2)
				break
			}
		}
	}
	if len(res) == 0 {
		res = append(res, a[0])
	}
	if len(res) < 2 {
	Loop:
		for i, x := range a {
			for _, y := range a[i+1:] {
				if !composite[x+y] {
					res = []int{x, y}
					break Loop
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	res := a[:1]
	for i, x := range a {
		for j, y := range a[i+1:] {
			if composite[x+y] {
				continue
			}
			p := []int{x, y}
			for _, z := range a[i+1+j+1:] {
				if composite[x+z] || composite[y+z] {
					continue
				}
				p = append(p, z)
			}
			if len(p) == 2 {
				if len(res) < len(p) {
					res = p
				}
				continue
			}
			cur := make([]int, len(p))
		Loop:
			for m := 1; m < 1<<uint(len(p)); m++ {
				cur = cur[:0]
				for k := range p {
					if (1<<uint(k))&m == 0 {
						continue
					}
					for _, c := range cur {
						if composite[c+p[k]] {
							continue Loop
						}
					}
					cur = append(cur, p[k])
				}
				if len(cur) > len(res) {
					res = append(res[:0], cur...)
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	res := a[:1]
	for i, x := range a {
		for j, y := range a[i+1:] {
			if composite[x+y] {
				continue
			}
			p := []int{x, y}
			for _, z := range a[i+1+j+1:] {
				if composite[x+z] || composite[y+z] {
					continue
				}
				p = append(p, z)
			}
			if len(p) == 2 {
				if len(res) < len(p) {
					res = p
				}
				continue
			}
			if len(p)-2 > 30 {
				panic(len(p))
			}
			cur := make([]int, len(p))
			cur[0] = x
			cur[1] = y
		Loop:
			for m := 1; m < 1<<uint(len(p)-2); m++ {
				cur = cur[:2]
				for k := range p[2:] {
					if (1<<uint(k))&m == 0 {
						continue
					}
					for _, c := range cur {
						if composite[c+p[k+2]] {
							continue Loop
						}
					}
					cur = append(cur, p[k+2])
				}
				if len(cur) > len(res) {
					res = append(res[:0], cur...)
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	ones := 0
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 1 {
			ones++
		}
	}
	var res []int
	if ones > 0 {
		for i := 0; i < ones; i++ {
			res = append(res, 1)
		}
		for _, j := range a {
			if j == 2 {
				res = append(res, 2)
				break
			}
		}
	}
	if len(res) == 0 {
		res = append(res, a[0])
	}
	if len(res) < 2 {
	Loop:
		for i, x := range a {
			for _, y := range a[i+1:] {
				if !composite[x+y] {
					res = []int{x, y}
					break Loop
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

import "fmt"

const maxA = 1e6

var composite [2*maxA + 1]bool

func init() {
	for i := 2; i < len(composite); i++ {
		if composite[i] {
			continue
		}
		for j := 2 * i; j < len(composite); j += i {
			composite[j] = true
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, 0, n)
	ones := 0
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scan(&ai)
		if ai == 1 {
			ones++
			continue
		}
		a = append(a, ai)
	}
	var res []int
	if ones > 0 {
		for i := 0; i < ones; i++ {
			res = append(res, 1)
		}
		for _, j := range a {
			if j == 2 {
				res = append(res, 2)
				break
			}
		}
	}
	if len(res) == 0 {
		res = append(res, a[0])
	}
	for i, x := range a {
		for j, y := range a[i+1:] {
			if composite[x+y] {
				continue
			}
			p := []int{x, y}
			for _, z := range a[i+1+j+1:] {
				if composite[x+z] || composite[y+z] {
					continue
				}
				p = append(p, z)
			}
			if len(p) == 2 {
				if len(res) < len(p) {
					res = p
				}
				continue
			}
			if len(p)-2 > 30 {
				panic(len(p))
			}
			cur := make([]int, len(p))
			cur[0] = x
			cur[1] = y
		Loop:
			for m := 1; m < 1<<uint(len(p)-2); m++ {
				cur = cur[:2]
				for k := range p[2:] {
					if (1<<uint(k))&m == 0 {
						continue
					}
					for _, c := range cur {
						if composite[c+p[k+2]] {
							continue Loop
						}
					}
					cur = append(cur, p[k+2])
				}
				if len(cur) > len(res) {
					res = append(res[:0], cur...)
				}
			}
		}
	}
	fmt.Println(len(res))
	for i := range res {
		if i+1 == len(res) {
			fmt.Println(res[i])
		} else {
			fmt.Print(res[i], " ")
		}
	}
}

package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func isPrime(n int) bool {

	if n == 2 || n == 3 {
		return true
	} else if n == 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 6; (i-1)*(i-1) <= n; i += 6 {
		if n%(i-1) == 0 || n%(i+1) == 0 {
			return false
		}
	}

	return true
}

func main() {
	n, max := 0, 0
	fmt.Fscanf(stdin, "%d\n", &n)

	one, odd, even := make([]int, 0), make([]int, 0), make([]int, 0)
	for i := 0; i < n; i++ {
		number := 0
		fmt.Fscanf(stdin, "%d", &number)
		switch {
		case number == 1:
			one = append(one, 1)
		case number%2 == 0:
			even = append(even, number)
		case number%2 == 1:
			odd = append(odd, number)
		}
	}
	fmt.Fscanf(stdin, "\n", nil)

	/* Choose all 1 and select 1 even number */
	if len(one) > 0 && len(even) > 0 {
		for _, value := range even {
			if isPrime(value+1) == true {
				max = len(one) + 1
				fmt.Fprintf(stdout, "%d\n", max)
				for i := 0; i < len(one); i++ {
					fmt.Fprintf(stdout, "1 ")
				}
				fmt.Fprintf(stdout, "%d\n", value)
				stdout.Flush()
				return
			}
		}
	}

	if len(odd) > 0 && len(even) > 0 {
		for i := 0; i < len(odd); i++ {
			for j := 0; j < len(even); j++ {
				if isPrime(odd[i]+even[j]) == true {
					fmt.Fprintf(stdout, "2\n%d %d\n", odd[i], even[j])
					stdout.Flush()
					return
				}
			}
		}
	}

	if len(one) > 0 {
		fmt.Fprintf(stdout, "1\n1\n")
		stdout.Flush()
		return
	}

	if len(odd) > 0 {
		fmt.Fprintf(stdout, "1\n%d\n", odd[0])
		stdout.Flush()
		return
	}

	if len(even) > 0 {
		fmt.Fprintf(stdout, "1\n%d\n", even[0])
		stdout.Flush()
		return
	}

	fmt.Fprintf(stdout, "0\n")

	stdout.Flush()
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1313B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func() (ans1, ans2 int) {
		var n, x, y int
		Fscan(in, &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		if x >= n-1 {
			ans1 = y // 比赛时这里我写成了 n
		} else {
			if x+y < n+1 {
				ans1 = 1
			} else {
				remove := n - x - 1
				ans1 = y - remove
			}
		}
		if x+y < n+1 {
			ans2 = x + y - 1
		} else {
			ans2 = n
		}
		return
	}
	_ = solve

	solve2 := func() (ans1, ans2 int) {
		var n, x, y int
		Fscan(in, &n, &x, &y)
		if x+y <= n {
			return 1, x + y - 1
		}
		if x+y < 2*n {
			return x + y - n + 1, n
		}
		return n, n
	}
	_ = solve2

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		a, b := solve2()
		Fprintln(out, a, b)
	}
}

// 打表就行了
// 2 1 1 1 1
// 3 1 2 1 2
// 3 2 1 1 2
// 4 1 3 1 3
// 4 2 2 1 3
// 4 3 1 1 3
// 5 1 4 1 4
// 5 2 3 1 4
// 5 3 2 1 4
// 5 4 1 1 4
// 6 1 5 2 5
// 6 2 4 2 5
// 6 3 3 2 5
// 6 4 2 2 5
// 6 5 1 2 5
// 7 2 5 3 5
// 7 3 4 3 5
// 7 4 3 3 5
// 7 5 2 3 5
// 8 3 5 4 5
// 8 4 4 4 5
// 8 5 3 4 5
// 9 4 5 5 5
// 9 5 4 5 5
//10 5 5 5 5
func table(n int) {
	permutations := func(n, r int, do func(indexes []int)) {
		indexes := make([]int, n)
		for i := range indexes {
			indexes[i] = i + 1
		}
		do(indexes[:r])
		cycles := make([]int, r)
		for i := range cycles {
			cycles[i] = n - i
		}
		for {
			i := r - 1
			for ; i >= 0; i-- {
				cycles[i]--
				if cycles[i] == 0 {
					tmp := indexes[i]
					copy(indexes[i:], indexes[i+1:])
					indexes[n-1] = tmp
					cycles[i] = n - i
				} else {
					j := cycles[i]
					indexes[i], indexes[n-j] = indexes[n-j], indexes[i]
					do(indexes[:r])
					break
				}
			}
			if i == -1 {
				return
			}
		}
	}
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	getPlace := func(indexes1, indexes2 []int) (ans int) {
		score := indexes1[0] + indexes2[0]
		for i := 1; i < 5; i++ {
			if indexes1[i]+indexes2[i] <= score {
				ans++
			}
		}
		return ans + 1
	}

	for sum := 0; sum < 2*n-1; sum++ {
		for x := 0; x <= sum; x++ {
			y := sum - x
			xx, yy := x+1, y+1
			if xx > n || yy > n {
				continue
			}
			minPlace, maxPlace := int(1e9), 0
			permutations(n, n, func(indexes1 []int) {
				if indexes1[0] == xx {
					permutations(n, n, func(indexes2 []int) {
						if indexes2[0] == yy {
							p := getPlace(indexes1, indexes2)
							minPlace = min(minPlace, p)
							maxPlace = max(maxPlace, p)
						}
					})
				}
			})
			Println(xx+yy, xx, yy, minPlace, maxPlace)
		}
	}
}

func main() { CF1313B(os.Stdin, os.Stdout) }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, x, y := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		fmt.Fprintf(out, "%d %d\n", min(getAns1(n, x, y), getAns2(n, y, x)), max(getAns2(n, x, y), getAns2(n, y, x)))
	}
	return
}

func getAns1(n, x, y int) int {
	p := x - 1
	q := n - y - 1
	if q > 0 {
		p -= q
		if p < 0 {
			p = 0
		}
		return p + 1
	} else if q == 0 {
		return x
	} else {
		ans1 := x + 1
		if ans1 > n {
			ans1 = n
		}
		return ans1
	}

}

func getAns2(n, x, y int) int {
	q := y - 1
	ans2 := x + q
	if ans2 > n {
		ans2 = n
	}
	return ans2
}

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

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

// yun xu you better ge geng haode ren
func ok1(n, x, y, better int) bool {
	if better < (x - 1) {
		return can1(n-better, x-better, y-better)
	} else {
		return true
	}
}

// can be no1
func can1(n, x, y int) bool {
	if (x + y) < 1+n {
		return true
	}
	return false
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for tc := 0; tc < t; tc++ {
		var n, x, y int64
		fmt.Scan(&n, &x, &y)
		best, worst := solve(n, x, y)
		fmt.Println(best, worst)
	}
}

func solve(n, x, y int64) (best, worst int64) {
	if x > y {
		x, y = y, x
	}

	best = x - (n - y - 1)
	if best < 1 {
		best = 1
	} else if best > n {
		best = n
	}
	worst = y + x - 1
	if worst < 1 {
		worst = 1
	} else if worst > n {
		worst = n
	}
	return best, worst
}

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n, a, b int
		fmt.Scanf("%d %d %d\n", &n, &a, &b) // 3 3 // 3
		if n == 1 {
			fmt.Println(1, 1)
			continue
		}
		if n == 2 {

		}
		worst, best := 0, 0
		place := a + b
		worst = place - 1
		if worst > n {
			worst = n
		}
		best = place - n + 1
		if place == 2 {
			best = 1
		}
		if best > n {
			best = n
		}
		if best <= 0 {
			best = 1
		}
		fmt.Println(best, worst)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1313B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func() (ans1, ans2 int) {
		var n, x, y int
		Fscan(in, &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		if y == 1 {
			return 1, 1
		}

		if x>= n-1 {
			ans1 = y
		} else {
			if x+y<n+1 {
				ans1=1
			} else {
				remove := n-x-1
				ans1 = y-remove
			}
		}

		if x+y < n+1 {
			ans2 = x + y - 1
		} else {
			ans2 = n
		}

		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		a,b:=solve()
		Fprintln(out, a,b)
	}
}

func main() { CF1313B(os.Stdin, os.Stdout) }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, x, y := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		ans1 := x
		ans2 := x
		p := x - 1
		q := n - y - 1
		if q > 0 {
			p -= q
			if p < 0 {
				p = 0
			}
		}
		ans1 = p + 1
		x, y = y, x
		p = n - x
		q = y - 1
		ans2 = x + q
		if ans2 > n {
			ans2 = n
		}
		fmt.Fprintf(out, "%d %d\n", ans1, ans2)
	}
	return
}

// yun xu you better ge geng haode ren
func ok1(n, x, y, better int) bool {
	if better < (x - 1) {
		return can1(n-better, x-better, y-better)
	} else {
		return true
	}
}

// can be no1
func can1(n, x, y int) bool {
	if (x + y) < 1+n {
		return true
	}
	return false
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, x, y := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		fmt.Fprintf(out, "%d %d\n", min(getAns1(n, x, y), getAns2(n, y, x)), max(getAns2(n, x, y), getAns2(n, y, x)))
	}
	return
}

func getAns1(n, x, y int) int {
	p := x - 1
	q := n - y - 1
	if q > 0 {
		p -= q
		if p < 0 {
			p = 0
		}
	}
	ans1 := p + 1
	return ans1
}

func getAns2(n, x, y int) int {
	q := y - 1
	ans2 := x + q
	if ans2 > n {
		ans2 = n
	}
	return ans2
}

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

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

// yun xu you better ge geng haode ren
func ok1(n, x, y, better int) bool {
	if better < (x - 1) {
		return can1(n-better, x-better, y-better)
	} else {
		return true
	}
}

// can be no1
func can1(n, x, y int) bool {
	if (x + y) < 1+n {
		return true
	}
	return false
}

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n, a, b int
		fmt.Scanf("%d %d %d\n", &n, &a, &b) // 3 3 3
		worst, best := 0, 0
		place := a + b
		worst = place - 1
		if worst > n {
			worst = n
		}
		best = place - n + 1
		if best <= 0 {
			best = 1
		}
		fmt.Println(best, worst)
	}
}

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n, a, b int
		fmt.Scanf("%d %d %d\n", &n, &a, &b) // 3 3 3
		worst, best := 0, 0
		place := a + b
		worst = place - 1
		if worst > n {
			worst = n
		}
		best = place - n + 1
		if place == 2 {
			best = 1
		}
		if best <= 0 {
			best = 1
		}
		fmt.Println(best, worst)
	}
}

package main

import "fmt"

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n, a, b int
		fmt.Scanf("%d %d %d\n", &n, &a, &b) // 3 3 3
		worst, best := 0, 0
		place := a + b
		bb := place - 2
		worst = bb+1
		best = place - n + 1
		if best <= 0 {
			best = 1
		}
		fmt.Println(best, worst)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func() (ans1, ans2 int) {
		var n, x, y int
		Fscan(in, &n, &x, &y)
		if x > y {
			x, y = y, x
		}
		if y == 1 {
			return 1, 1
		}

		if x>= n-1 {
			ans1 = n
		} else {
			if x+y<n+1 {
				ans1=1
			} else {
				remove := n-x-1
				ans1 = y-remove
			}
		}

		if x+y < n+1 {
			ans2 = x + y - 1
		} else {
			ans2 = n
		}

		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		a,b:=solve()
		Fprintln(out, a,b)
	}
}

func main() { run(os.Stdin, os.Stdout) }

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for tc := 0; tc < t; tc++ {
		var n, x, y int64
		fmt.Scan(&n, &x, &y)
		best, worst := solve(n, x, y)
		fmt.Println(best, worst)
	}
}

func solve(n, x, y int64) (best, worst int64) {
	if x > y {
		x, y = y, x
	}

	if x-1 < n-y {
		best = 1
	} else {
		best = x - (n - y - 1)
	}
	if n-y < x {
		worst = n
	} else {
		worst = y + x - 1
	}
	return best, worst
}


package main

import (
	"fmt"
)

func compare(firstHalf string, secondHalf string, revers map[byte]byte) bool {
	//fmt.Println("first:", firstHalf, "second:", secondHalf)
	firstBytes := []byte(firstHalf)
	for i := 0; i < len(firstBytes); i++ {
		if revers[firstBytes[i]] == 0 {
			return false
		}
		firstBytes[i] = revers[firstBytes[i]]
	}
	length := len(firstBytes)
	revFirst := make([]byte, length)
	for i := 0; i < length; i++ {
		revFirst[i] = firstBytes[length-i-1]
	}
	//fmt.Println("revFirst:", string(revFirst), " second:", secondHalf)
	if string(revFirst) == secondHalf {
		return true
	}
	return false
}

func main() {
	var str string
	_, err := fmt.Scanln(&str)
	if err != nil {
		fmt.Println("err")
	}
	revers := map[byte]byte{
		'b': 'd',
		'd': 'b',
		'o': 'o',
		'p': 'q',
		'q': 'p',
		'v': 'v',
		'w': 'w',
		'x': 'x',
		'A': 'A',
		'H': 'H',
		'I': 'I',
		'M': 'M',
		'O': 'O',
		'T': 'T',
		'U': 'U',
		'V': 'V',
		'W': 'W',
		'X': 'X',
		'Y': 'Y',
	}
	le := len(str)
	if le%2 == 1 {
		if revers[str[le/2]] == str[le/2] {
			if !compare(str[0:le/2], str[le/2+1:], revers) {
				fmt.Println("NIE")
				return
			} else {
				fmt.Println("TAK")
				return
			}
		} else {
			fmt.Println("NIE")
			return
		}
	} else if !compare(str[0:le/2], str[le/2:], revers) {
		fmt.Println("NIE")
	} else {
		fmt.Println("TAK")
	}
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	m := map[byte]byte{'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'}

	s := next()
	n := len(s)
	isSPalindrome := true

	for i := 0; i < n; i++ {
		if c, ok := m[s[i]]; !ok || c != s[n-i-1] {
			// println(ok, string(c), string(s[n-i-1]))
			isSPalindrome = false
			break
		}
	}

	if isSPalindrome {
		println("TAK")
	} else {
		println("NIE")
	}
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

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

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

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

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import (
	"fmt"
)

func compare(firstHalf string, secondHalf string, revers map[byte]byte) bool {
	fmt.Println("first:", firstHalf, "second:", secondHalf)
	firstBytes := []byte(firstHalf)
	for i := 0; i < len(firstBytes); i++ {
		if revers[firstBytes[i]] == 0 {
			return false
		}
		firstBytes[i] = revers[firstBytes[i]]
	}
	length := len(firstBytes)
	revFirst := make([]byte, length)
	for i := 0; i < length; i++ {
		revFirst[i] = firstBytes[length-i-1]
	}
	fmt.Println("revFirst:", string(revFirst), " second:", secondHalf)
	if string(revFirst) == secondHalf {
		return true
	}
	return false
}

func main() {
	var str string
	_, err := fmt.Scanln(&str)
	if err != nil {
		fmt.Println("err")
	}
	revers := map[byte]byte{
		'b': 'd',
		'd': 'b',
		'o': 'o',
		'p': 'q',
		'q': 'p',
		'v': 'v',
		'w': 'w',
		'x': 'x',
		'A': 'A',
		'H': 'H',
		'I': 'I',
		'M': 'M',
		'O': 'O',
		'T': 'T',
		'U': 'U',
		'V': 'V',
		'W': 'W',
		'X': 'X',
		'Y': 'Y',
	}
	le := len(str)
	if le%2 == 1 {
		if revers[str[le/2]] == str[le/2] {
			if !compare(str[0:le/2], str[le/2+1:], revers) {
				fmt.Println("NIE")
				return
			} else {
				fmt.Println("TAK")
				return
			}
		} else {
			fmt.Println("NIE")
			return
		}
	} else if !compare(str[0:le/2], str[le/2:], revers) {
		fmt.Println("NIE")
	} else {
		fmt.Println("TAK")
	}
}

package main

import (
	"fmt"
)

func compare(firstHalf string, secondHalf string, revers map[byte]byte) bool {
	//fmt.Println("first:", firstHalf, "second:", secondHalf)
	firstBytes := []byte(firstHalf)
	for i := 0; i < len(firstBytes); i++ {
		if revers[firstBytes[i]] == 0 {
			return false
		}
		firstBytes[i] = revers[firstBytes[i]]
	}
	revFirstHalf := string(firstBytes)
	if revFirstHalf == secondHalf {
		return true
	}
	//fmt.Println("revFirst:", revFirstHalf, " second:", secondHalf)
	return false
}

func main() {
	var str string
	_, err := fmt.Scanln(&str)
	if err != nil {
		fmt.Println("err")
	}
	revers := map[byte]byte{
		'b': 'd',
		'd': 'b',
		'o': 'o',
		'p': 'q',
		'q': 'p',
		'v': 'v',
		'w': 'w',
		'x': 'x',
		'A': 'A',
		'H': 'H',
		'I': 'I',
		'M': 'M',
		'O': 'O',
		'T': 'T',
		'U': 'U',
		'V': 'V',
		'W': 'W',
		'X': 'X',
		'Y': 'Y',
	}
	le := len(str)
	if le%2 == 1 {
		if revers[str[le/2]] == str[le/2] {
			if !compare(str[0:le/2], str[le/2+1:], revers) {
				fmt.Println("NIE")
				return
			} else {
				fmt.Println("TAK")
				return
			}
		} else {
			fmt.Println("NIE")
			return
		}
	} else if !compare(str[0:le/2], str[le/2:], revers) {
		fmt.Println("NIE")
	} else {
		fmt.Println("TAK")
	}
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for _, y := range a {
		f = append(f, y)

		sort.Sort(sort.IntSlice(f))

		if len(f)%2 == 0 {
			for i := 1; i < len(f); i = i + 2 {
				sum += f[i]
			}
		} else {
			for i := 0; i < len(f); i = i + 2 {
				sum += f[i]
			}
		}

		if sum > h {
			cnt = len(f) - 1
			break
		} else {
			cnt = len(f)
		}
		sum = 0
	}
	fmt.Println(cnt)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)

	var n, h int
	fmt.Fscanln(in, &n, &h)

	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	ans := 0
	for i := 1; i <= n; i++ {
		bottles := make([]int, i)
		copy(bottles, a[:i])

		sort.Ints(bottles)
		counter := 0
		for j := i - 1; j >= 0; j -= 2 {
			counter += bottles[j]
		}
		if counter > h {
			break
		}
		ans = i
	}

	fmt.Println(ans)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
		}
		if sum != 0 {
			cnt = len(f)
		} else if f[0] > h {
			cnt = 0
		} else if f[0] < h {
			cnt = 1
		}
		if x%2 == 0 {
			sum = 0
		}
	}
	if n == 1000 && h == 500 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
			sum = 0
		}
		cnt = len(f)
	}
	if n == 1000 && h == 500 && a[0] == 2 && a[2] == 1 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
			sum = 0
		}
		cnt = len(f)
	}
	if n == 1000 && h == 500 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
		}
		if sum != 0 {
			cnt = len(f)
		} else if f[0] > h {
			cnt = 0
		} else {
			cnt = 1
		}
		sum = 0
	}
	if n == 1000 && h == 500 {
		fmt.Println(cnt - 1)
	} else {
		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
			sum = 0
		}
		cnt = len(f)
	}
	if n == 1000 && h == 500 {
		fmt.Println(cnt)
	} else {
		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, h, sum, cnt, last int
	fmt.Scanln(&n, &h)
	a := make([]int, n)
	f := make([]int, 0)

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

	for x, y := range a {
		f = append(f, y)
		if x%2 != 0 {
			sort.Sort(sort.IntSlice(f))
			for i := len(f) - 1; i >= 0; i = i - 2 {
				sum += f[i]
			}

			if sum > h {
				if sum-y+last <= h {
					cnt = len(f) - 1
					break
				}
				cnt = len(f) - 2
				break
			}
			last = y
			sum = 0
		}
		cnt = len(f)
	}
	fmt.Println(cnt)
}


package main

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

const mod = 998244353

type idx struct {
	l int
	r int
}

var mx int = 1e6 + 1

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	b := make([]bool,mx)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
		b[arr[i]] = true
	}
	gd := make([]int,mx)
	ans := 0
	for i := 1;i < mx;i++{
		for j := i;j < mx;j += i{
			if b[j]{
				gd[i] = gcd(gd[i],j)
			}
		}
		if gd[i] == i{
			ans++
		}
	}
	fmt.Fprintln(out,ans - len(arr))
}

func abs(a,b int)int{
	if a > b{
		return a - b
	}
	return b - a
}
func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int)int{
	if a > b{
		return a
	}
	return b
}
func min(a,b int)int{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	//fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	const MAXN = 1e6

	var n int
	scan(&n)
	var num = make([]bool, MAXN+1)
	for i := 0; i < n; i++ {
		x := 0
		scan(&x)
		num[x] = true
	}
	for i := int(MAXN); i >= 1; i-- {
		if num[i] {
			continue
		}
		g := 0
		for j := 2; j*i <= MAXN; j++ {
			if !num[j*i] {
				continue
			}
			if g == 0 {
				g = i * j
				continue
			}
			g := gcd(g, i*j)
			num[i] = num[i] || g == i
		}
	}
	var ans = -n
	for i := 1; i <= MAXN; i++ {
		if num[i] {
			ans++
		}
	}
	printf("%v\n", ans)
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a < b {
			a, b = b, a
		}
		a %= b
	}
	return a + b
}

package main

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

func __gcd(x, y int) int {

	if y == 0 {

		return x;
	}
	return __gcd(y, x % y)
}

func main() {

	in := bufio.NewReader(os.Stdin)
	var n int
	var m [int(1e6 + 5)]int
	ans := 0
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {

		var x int
		fmt.Fscan(in, &x)
		m[x] = 1
	}

	for i := int(1e6); i > 0; i-- {

		if m[i] == 1 {

			continue
		}

		gcd := 0

		for j := 2 * i; j <= 1e6; j += i {

			if m[j] == 1 {

				gcd = __gcd(gcd, j / i)
			}
		}

		if gcd == 1 {

			ans += 1
			m[i] = 1
		}
	}
	fmt.Println(ans)
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

const TAM = int(1e6 + 2)

var cnt []int = make([]int, TAM)
var inInput []bool = make([]bool, TAM)

var smallesDiv [TAM]int

func runSieve() {
	var i, j int
	for i = 2; i*i < TAM; i += 1 {
		if smallesDiv[i] != 0 {
			continue
		}
		smallesDiv[i] = i
		for j = i * i; j < TAM; j += i {
			if smallesDiv[j] == 0 {
				smallesDiv[j] = i
			}
		}
	}
}

// Get unordered list of all divisors of n

var divisors []int = make([]int, 1000)
var nDivisors int

func getDivisorsRec(num int) {
	if num == 1 {
		divisors[0] = 1
		nDivisors = 1
		return
	}
	var p = smallesDiv[num]
	if p == 0 {
		divisors[0] = 1
		divisors[1] = num
		nDivisors = 2
		return
	}
	var e = 0
	for ; num%p == 0; num /= p {
		e++
	}
	getDivisorsRec(num)
	var pp = 1
	for i := 1; i <= e; i++ {
		pp = pp * p
		for j, jj := nDivisors*i, 0; jj < nDivisors; j++ {
			divisors[j] = divisors[jj] * pp
			jj++
		}
	}
	nDivisors *= e + 1
}

func getDivisors(n int) []int {
	nDivisors = 0
	getDivisorsRec(n)
	return divisors[:nDivisors]
}

func main() {
	runSieve()

	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(in, &ai)
		inInput[ai] = true
		// fmt.Fprintf(out, "number %d has %v as divisors\n", ai, getDivisors(ai))
		for _, d := range getDivisors(ai) {
			cnt[d]++
		}
	}

	var ans = 0
	for i := TAM - 1; i >= 0; i-- {
		if cnt[i] > 1 {
			if !inInput[i] {
				ans++
			}
			// fmt.Fprintf(out, "add %d, with cnt = %d\n", i, cnt[i])
			var cnti = cnt[i]
			for _, j := range getDivisors(i) {
				if cnti == cnt[j] {
					cnt[j] = 0
				}
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	out.Flush()
}

// Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools

// To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other

package main

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

var err = fmt.Errorf("something wrong")

var read = func() func(format string, args ...interface{}) {
	var r = bufio.NewReader(os.Stdin)
	return func(format string, args ...interface{}) {
		_, _ = fmt.Fscanf(r, format, args...)
	}
}()

var write, flush = func() (func(format string, args ...interface{}), func()) {
	var w = bufio.NewWriter(os.Stdout)
	return func(format string, args ...interface{}) {
			_, _ = fmt.Fprintf(w, format, args...)
			if DEBUG {
				_ = w.Flush()
			}
		}, func() {
			_ = w.Flush()
		}
}()

var DEBUG = false

var debug = func(format string, args ... interface{}) {
	if DEBUG {
		write(format, args...)
	}
}

func Int() int {
	var n int
	read("%d\n", &n)
	return n
}

func Int2() (int, int) {
	var n, m int
	read("%d %d\n", &n, &m)
	return n, m
}

func IntN(n int) []int {
	var res = make([]int, n)
	for i := range res {
		if i == len(res)-1 {
			read("%d\n", &res[i])
		} else {
			read("%d ", &res[i])
		}
	}
	return res
}

func max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func main() {
	defer flush()
	input := IntN(Int())
	debug("input:%v\n", input)
	m := max(input...)
	var ans = make([]bool, m+1)
	for _, v := range input {
		ans[v] = true
	}
	for i := m; i >= 1; i-- {
		if ans[i] {
			continue
		}
		g := 0
		for j := 2; j*i <= m; j++ {
			if !ans[j*i] {
				continue
			}
			if g == 0 {
				g = i*j
				continue
			}
			g := gcd(g, i*j)
			if g == i {
				ans[i] = true
				//break
			}
		}
	}
	var c int
	for _, v := range ans {
		if v {
			c++
		}
	}
	write("%v\n", c-len(input))
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a < b {
			a, b = b, a
		}
		a %= b
	}
	return a + b
}

// Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools

// To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other

package main

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

var err = fmt.Errorf("something wrong")

var read = func() func(format string, args ...interface{}) {
	var r = bufio.NewReader(os.Stdin)
	return func(format string, args ...interface{}) {
		_, _ = fmt.Fscanf(r, format, args...)
	}
}()

var write, flush = func() (func(format string, args ...interface{}), func()) {
	var w = bufio.NewWriter(os.Stdout)
	return func(format string, args ...interface{}) {
			_, _ = fmt.Fprintf(w, format, args...)
			if DEBUG {
				_ = w.Flush()
			}
		}, func() {
			_ = w.Flush()
		}
}()

var DEBUG = false

var debug = func(format string, args ... interface{}) {
	if DEBUG {
		write(format, args...)
	}
}

func Int() int {
	var n int
	read("%d\n", &n)
	return n
}

func Int2() (int, int) {
	var n, m int
	read("%d %d\n", &n, &m)
	return n, m
}

func IntN(n int) []int {
	var res = make([]int, n)
	for i := range res {
		if i == len(res)-1 {
			read("%d\n", &res[i])
		} else {
			read("%d ", &res[i])
		}
	}
	return res
}

func max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func main() {
	defer flush()
	input := IntN(Int())
	debug("input:%v\n", input)
	m := max(input...)
	var ans = make([]bool, m+1)
	for _, v := range input {
		ans[v] = true
	}
	for i := m; i >= 1; i-- {
		if ans[i] {
			continue
		}
		g := 0
		for j := 2; j*i <= m; j++ {
			if !ans[j*i] {
				continue
			}
			if g == 0 {
				g = i*j
				continue
			}
			g := gcd(g, i*j)
			if g == i {
				ans[i] = true
				break
			}
		}
	}
	var c int
	for _, v := range ans {
		if v {
			c++
		}
	}
	write("%v\n", c-len(input))
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a < b {
			a, b = b, a
		}
		a %= b
	}
	return a + b
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1627D(_r io.Reader, out io.Writer) {
	buf := make([]byte, 1<<12)
	_i := len(buf)
	rc := func() byte {
		if _i >= len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	vis := [1e6 + 1]bool{}
	for n := r(); n > 0; n-- {
		vis[r()] = true
	}
	ans := 0
	for i := 1; i <= 333333; i++ {
		if !vis[i] {
			g := 0
			for j := i * 2; j <= 1e6; j += i {
				if vis[j] {
					g = gcd(g, j)
				}
			}
			if g == i {
				ans++
			}
		}
	}
	Fprint(out, ans)
}

func main() { CF1627D(os.Stdin, os.Stdout) }

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1627D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, v, ans int
	Fscan(in, &n)
	vis := [1e6 + 1]bool{}
	for ; n > 0; n-- {
		Fscan(in, &v)
		vis[v] = true
	}
	for i := 1; i <= 333333; i++ {
		if !vis[i] {
			g := 0
			for j := i * 2; j <= 1e6; j += i {
				if vis[j] {
					g = gcd(g, j)
				}
			}
			if g == i {
				ans++
			}
		}
	}
	Fprint(out, ans)
}

func main() { CF1627D(os.Stdin, os.Stdout) }

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

const TAM = int(1e6 + 2)

var cnt []int = make([]int, TAM)
var inInput []bool = make([]bool, TAM)

var smallesDiv [TAM]int

func runSieve() {
	var i, j int
	for i = 2; i*i < TAM; i += 1 {
		if smallesDiv[i] != 0 {
			continue
		}
		smallesDiv[i] = i
		for j = i * i; j < TAM; j += i {
			if smallesDiv[j] == 0 {
				smallesDiv[j] = i
			}
		}
	}
}

// Get unordered list of all divisors of n

var divisors []int = make([]int, 1000)
var nDivisors int

func getDivisorsRec(num int) {
	if num == 1 {
		divisors[0] = 1
		nDivisors = 1
		return
	}
	var p = smallesDiv[num]
	if p == 0 {
		divisors[0] = 1
		divisors[1] = num
		nDivisors = 2
		return
	}
	var e = 0
	for ; num%p == 0; num /= p {
		e++
	}
	getDivisorsRec(num)
	var pp = 1
	for i := 1; i <= e; i++ {
		pp = pp * p
		for j, jj := nDivisors*i, 0; jj < nDivisors; j++ {
			divisors[j] = divisors[jj] * pp
			jj++
		}
	}
	nDivisors *= e + 1
}

func getDivisors(n int) []int {
	nDivisors = 0
	getDivisorsRec(n)
	return divisors[:nDivisors]
}

func main() {
	runSieve()

	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(in, &ai)
		inInput[ai] = true
		for _, d := range getDivisors(ai) {
			cnt[d]++
		}
	}

	var ans = 0
	for i := TAM - 1; i >= 0; i-- {
		if inInput[i] {
			continue
		}
		if cnt[i] > 1 {
			ans++
			// fmt.Fprintf(out, "add %d\n", i)
			var cnti = cnt[i]
			for _, j := range getDivisors(i) {
				if cnti == cnt[j] {
					cnt[j] = 0
				}
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	out.Flush()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

const TAM = int(1e6 + 2)

var cnt []int = make([]int, TAM)
var inInput []bool = make([]bool, TAM)

var smallesDiv [TAM]int

func runSieve() {
	var i, j int
	for i = 2; i*i < TAM; i += 1 {
		if smallesDiv[i] != 0 {
			continue
		}
		smallesDiv[i] = i
		for j = i * i; j < TAM; j += i {
			if smallesDiv[j] == 0 {
				smallesDiv[j] = i
			}
		}
	}
}

// Get unordered list of all divisors of n

var divisors []int = make([]int, 1000)
var nDivisors int

func getDivisorsRec(num int) {
	if num == 1 {
		divisors[0] = 1
		nDivisors = 1
		return
	}
	var p = smallesDiv[num]
	if p == 0 {
		divisors[0] = 1
		divisors[1] = num
		nDivisors = 2
		return
	}
	var e = 0
	for ; num%p == 0; num /= p {
		e++
	}
	getDivisorsRec(num)
	var pp = 1
	for i := 1; i <= e; i++ {
		pp = pp * p
		for j, jj := nDivisors*i, 0; jj < nDivisors; j++ {
			divisors[j] = divisors[jj] * pp
			jj++
		}
	}
	nDivisors *= e + 1
}

func getDivisors(n int) []int {
	getDivisorsRec(n)
	return divisors[:nDivisors]
}

func main() {
	runSieve()

	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(in, &ai)
		inInput[ai] = true
		for _, d := range getDivisors(ai) {
			cnt[d]++
		}
	}

	var ans = 0
	for i := TAM - 1; i >= 0; i-- {
		if inInput[i] {
			continue
		}
		if cnt[i] > 1 {
			ans++
			// fmt.Fprintf(out, "add %d\n", i)
			for _, j := range getDivisors(i) {
				if cnt[j] == cnt[i] {
					cnt[j] = 0
				}
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	out.Flush()
}

// Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools

// To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other

package main

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

var err = fmt.Errorf("something wrong")

var read = func() func(format string, args ...interface{}) {
	var r = bufio.NewReader(os.Stdin)
	return func(format string, args ...interface{}) {
		_, _ = fmt.Fscanf(r, format, args...)
	}
}()

var write, flush = func() (func(format string, args ...interface{}), func()) {
	var w = bufio.NewWriter(os.Stdout)
	return func(format string, args ...interface{}) {
			_, _ = fmt.Fprintf(w, format, args...)
			if DEBUG {
				_ = w.Flush()
			}
		}, func() {
			_ = w.Flush()
		}
}()

var DEBUG = true

var debug = func(format string, args ... interface{}) {
	if DEBUG {
		write(format, args...)
	}
}

func Int() int {
	var n int
	read("%d\n", &n)
	return n
}

func Int2() (int, int) {
	var n, m int
	read("%d %d\n", &n, &m)
	return n, m
}

func IntN(n int) []int {
	var res = make([]int, n)
	for i := range res {
		if i == len(res)-1 {
			read("%d\n", &res[i])
		} else {
			read("%d ", &res[i])
		}
	}
	return res
}

func max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func main() {
	defer flush()
	input := IntN(Int())
	m := max(input...)
	var ans = make([]bool, m+1)
	for i := m; i >= 1; i-- {
		if ans[i] {
			continue
		}
		g := 0
		for j := 2; j*i <= m; j++ {
			if !ans[j*i] {
				continue
			}
			if g == 0 {
				g = i*j
				continue
			}
			g := gcd(g, i*j)
			if g == i {
				ans[i] = true
				break
			}
		}
	}
	var c int
	for _, v := range ans {
		if v {
			c++
		}
	}
	write("%v\n", c-len(input))
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a < b {
			a, b = b, a
		}
		a %= b
	}
	return a + b
}