Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table $$$M$$$ with $$$n$$$ rows and $$$n$$$ columns such that $$$M_{ij}=a_i \cdot a_j$$$ where $$$a_1, \dots, a_n$$$ is some sequence of positive integers.Of course, the girl decided to take it to school with her. But while she was having lunch, hooligan Grisha erased numbers on the main diagonal and threw away the array $$$a_1, \dots, a_n$$$. Help Sasha restore the array!

The first line contains a single integer $$$n$$$ ($$$3 \leqslant n \leqslant 10^3$$$), the size of the table.  The next $$$n$$$ lines contain $$$n$$$ integers each. The $$$j$$$-th number of the $$$i$$$-th line contains the number $$$M_{ij}$$$ ($$$1 \leq M_{ij} \leq 10^9$$$). The table has zeroes on the main diagonal, that is, $$$M_{ii}=0$$$.

In a single line print $$$n$$$ integers, the original array $$$a_1, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$). It is guaranteed that an answer exists. If there are multiple answers, print any.

package main

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

func clear(arr []byte) []byte {
	if string(arr[len(arr)-2:len(arr)]) == "\r\n" {
		return arr[:len(arr)-2]
	} else if string(arr[len(arr)-1]) == "\n" {
		return arr[:len(arr)-1]
	}
	return arr
}

func main() {
	var input [][]byte
	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadBytes('\n')
	n, _ := strconv.Atoi(string(clear(line1)))
	for i := 0; i < n; i++ {
		line, _ := reader.ReadBytes('\n')
		input = append(input, clear(line))
	}

	var m01, m02, m12 float64

	values := strings.Split(string(input[0]), " ")
	for k, i := range strings.Split(string(input[0]), " ") {
		if k > 2 {
			break
		} else if k == 1 {
			v, _ := strconv.Atoi(i)
			m01 = float64(v)
		} else if k == 2 {
			v, _ := strconv.Atoi(i)
			m02 = float64(v)
		}
	}
	for k, i := range strings.Split(string(input[1]), " ") {
		if k > 2 {
			break
		} else if k == 2 {
			v, _ := strconv.Atoi(i)
			m12 = float64(v)
		}
	}
	a0 := int(math.Sqrt((m01 * m02) / m12))
	result := strconv.Itoa(a0)
	for i := 1; i < n; i++ {
		k, _ := strconv.Atoi(values[i])
		result += " " + strconv.Itoa(k/a0)
	}
	fmt.Printf("%v", result)
}

package main

import (
	"bufio"
	"math"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {

	n := readInt()
	arr := make([]int64, n+3)

	for i := 0; i < n+3; i++ {
		arr[i] = readInt64()
	}

	a := math.Sqrt(float64(1)*float64(arr[1])*float64(arr[2])/float64(arr[n+2]) + 0.0000001)

	aa := int64(a)
	printInt64(aa)
	for i := 1; i < n; i++ {
		printInt64(arr[i] / aa)
	}

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString(" ")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	aa := make([]big.Int, n)
	b := make([]big.Int, 3)
	for i := 0; i < n; i++ {
		aa[i].SetInt64(int64(nextInt()))
	}
	for j := 0; j < 3; j++ {
		b[j].SetInt64(int64(nextInt()))
		//for i := 0; i < n; i++ {
		//	b[j] = append(b[j], new(big.Int).SetInt64(int64(nextInt())))
		//}
	}
	var a big.Int
	a.Mul(&aa[1], &aa[2])
	a.Quo(&a, &b[2])
	a.Sqrt(&a)
	//a := int(math.Sqrt(float64(aa[1] * aa[2] / b[0][2])))
	fmt.Fprint(writer, a.String(), " ")
	var tmp big.Int
	for i := 1; i < n; i++ {
		tmp.Quo(&aa[i], &a)
		fmt.Fprint(writer, tmp.String(), " ")
	}
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

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

/*
URL:
https://codeforces.com/problemset/problem/1220/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 (
	n int
	M [][]int64
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		row := ReadInt64Slice(n)
		M = append(M, row)
	}

	var a0 int64
	a := M[0][1] * M[0][2] / M[1][2]
	for i := int64(1); ; i++ {
		if i*i == a {
			a0 = i
			break
		}
	}

	A := []int64{a0}
	for i := 1; i < n; i++ {
		A = append(A, M[0][i]/a0)
	}
	fmt.Println(PrintInts64Line(A...))
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	// if a <= 0 || b <= 0 {
	// 	panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	// }
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/*********** 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...)
}

/*
URL:
https://codeforces.com/problemset/problem/1220/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 (
	n int
	M [][]int64
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		row := ReadInt64Slice(n)
		M = append(M, row)
	}

	a := M[0][1] * M[0][2] / M[1][2]
	// for i := int64(1); ; i++ {
	// 	if i*i == a {
	// 		a0 = i
	// 		break
	// 	}
	// }
	a0 := BinarySearch(1000000000, 0, func(mid int64) bool { return mid*mid >= a })

	A := []int64{a0}
	for i := 1; i < n; i++ {
		A = append(A, M[0][i]/a0)
	}
	fmt.Println(PrintInts64Line(A...))
}

func BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	// if a <= 0 || b <= 0 {
	// 	panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	// }
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/*********** 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"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	defer Flush()

	n := readi()
	M := make([][]int64, n)
	for i := range M {
		M[i] = make([]int64, n)
		for j := range M[i] {
			M[i][j] = readll()
		}
	}

	a := solve(n, M)
	sp := ""
	for _, v := range a {
		printf("%s%d", sp, v)
		sp = " "
	}
	println()
}

func solve(n int, M [][]int64) []int64 {
	d := M[0][1]
	for i := 2; i < n; i++ {
		d = gcdll(d, M[0][i])
	}

	a := make([]int64, n)
	for i := int64(1); i*i <= d; i++ {
		if d%i != 0 {
			continue
		}
		a[0] = i
		a[1] = M[0][1] / a[0]
		a[2] = M[0][2] / a[0]
		if a[1]*a[2] == M[1][2] {
			break
		}
		a[0] = d / i
		a[1] = M[0][1] / a[0]
		a[2] = M[0][2] / a[0]
		if a[1]*a[2] == M[1][2] {
			break
		}
	}
	for i := 3; i < n; i++ {
		a[i] = M[0][i] / a[0]
	}
	return a
}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Utilities

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

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

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

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

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// Author: sighduck
// URL: https://codeforces.com/contest/1220/problem/B

package main

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

func Solve(n int, m [][]int64) []int64 {
	answer := []int64{}
	a1 := int64(math.Sqrt(float64(m[0][1] * m[0][2] / m[1][2])))
	answer = append(answer, a1)
	for i := 1; i < n; i++ {
		answer = append(answer, m[0][i]/a1)
	}
	return answer
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	m := make([][]int64, n)
	for i := 0; i < n; i++ {
		m[i] = make([]int64, n)
		for j := 0; j < n; j++ {
			fmt.Fscanf(reader, "%d", &m[i][j])
		}
		fmt.Fscanf(reader, "\n")
	}

	for _, elem := range Solve(n, m) {
		fmt.Fprintf(writer, "%d ", elem)
	}
	fmt.Fprintf(writer, "\n")
}

package main

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

func clear(arr []byte) []byte {
	if string(arr[len(arr)-2:len(arr)]) == "\r\n" {
		return arr[:len(arr)-2]
	} else if string(arr[len(arr)-1]) == "\n" {
		return arr[:len(arr)-1]
	}
	return arr
}

func main() {
	var input [][]byte
	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadBytes('\n')
	n, _ := strconv.Atoi(string(clear(line1)))

	for i := 0; i < n; i++ {
		line, _ := reader.ReadBytes('\n')
		input = append(input, clear(line))
	}

	var a0, m01, m02, m12 int

	values := strings.Split(string(input[0]), " ")

	for k, i := range strings.Split(string(input[0]), " ") {
		if k > 2 {
			break
		} else if k == 1 {
			m01, _ = strconv.Atoi(i)
		} else if k == 2 {
			m02, _ = strconv.Atoi(i)
		}
	}
	for k, i := range strings.Split(string(input[1]), " ") {
		if k > 2 {
			break
		} else if k == 2 {
			m12, _ = strconv.Atoi(i)
		}
	}
	a0 = int(math.Sqrt(float64((m01 * m02) / m12)))

	result := strconv.Itoa(a0)
	for i := 1; i < n; i++ {
		k, _ := strconv.Atoi(values[i])
		result += " " + strconv.Itoa(k/a0)
	}
	fmt.Printf("%v", result)
}

package main

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

func clear(arr []byte) []byte {
	if string(arr[len(arr)-2:len(arr)]) == "\r\n" {
		return arr[:len(arr)-2]
	} else if string(arr[len(arr)-1]) == "\n" {
		return arr[:len(arr)-1]
	}
	return arr
}

func main() {
	var input [][]byte
	reader := bufio.NewReader(os.Stdin)
	line1, _ := reader.ReadBytes('\n')
	n, _ := strconv.Atoi(string(clear(line1)))
	fmt.Println(n)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadBytes('\n')
		input = append(input, clear(line))
	}

	var m01, m02, m12 float64

	values := strings.Split(string(input[0]), " ")
	fmt.Printf("%v\n", values)
	for k, i := range strings.Split(string(input[0]), " ") {
		if k > 2 {
			break
		} else if k == 1 {
			v, _ := strconv.Atoi(i)
			m01 = float64(v)
		} else if k == 2 {
			v, _ := strconv.Atoi(i)
			m02 = float64(v)
		}
	}
	for k, i := range strings.Split(string(input[1]), " ") {
		if k > 2 {
			break
		} else if k == 2 {
			v, _ := strconv.Atoi(i)
			m12 = float64(v)
		}
	}
	a0 := int(math.Sqrt((m01 * m02) / m12))
	result := strconv.Itoa(a0)
	for i := 1; i < n; i++ {
		k, _ := strconv.Atoi(values[i])
		result += " " + strconv.Itoa(k/a0)
	}
	fmt.Printf("%v", result)
}

package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	aa := make([]int, n)
	b := make([][]int, n-1)
	for i := 0; i < n; i++ {
		aa[i] = nextInt()
	}
	for j := 0; j < n-1; j++ {
		for i := 0; i < n; i++ {
			b[j] = append(b[j], nextInt())
		}
	}
	a := int(math.Sqrt(float64(aa[1] * aa[2] / b[0][2])))
	fmt.Fprint(writer, a, " ")
	for i := 1; i < n; i++ {
		tmp := aa[i] / a
		fmt.Fprint(writer, tmp, " ")
	}
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

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

package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	aa := make([]int, n)
	b := make([]int, 3)
	for i := 0; i < n; i++ {
		aa[i] = nextInt()
	}
	for i := 0; i < 3; i++ {
		b[i] = nextInt()
	}
	a := int(math.Sqrt(float64(aa[1] * aa[2] / b[2])))
	fmt.Fprint(writer, a, " ")
	for i := 1; i < n; i++ {
		tmp := aa[i] / a
		fmt.Fprint(writer, tmp, " ")
	}
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

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

/*
URL:
https://codeforces.com/problemset/problem/1220/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 (
	n int
	M [][]int
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		row := ReadIntSlice(n)
		M = append(M, row)
	}

	var a0 int
	a := M[0][1] * M[0][2] / M[1][2]
	for i := 1; i*i <= 1000000000; i++ {
		if i*i == a {
			a0 = i
			break
		}
	}

	A := []int{a0}
	for i := 1; i < n; i++ {
		A = append(A, M[0][i]/a0)
	}
	fmt.Println(PrintIntsLine(A...))
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	// if a <= 0 || b <= 0 {
	// 	panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	// }
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/*********** 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...)
}

/*
URL:
https://codeforces.com/problemset/problem/1220/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 (
	n int
	M [][]int
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		row := ReadIntSlice(n)
		M = append(M, row)
	}

	G := make([]int, n)
	for i := 0; i < n; i++ {
		g := 0
		for j := 0; j < n; j++ {
			g = Gcd(g, M[i][j])
		}
		G[i] = g
	}

	g := G[0]
	answers := []int{g}
	for i := 1; i < n; i++ {
		a := M[0][i] / g
		answers = append(answers, a)
	}
	fmt.Println(PrintIntsLine(answers...))
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	// if a <= 0 || b <= 0 {
	// 	panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	// }
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/*********** 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...)
}

/*
URL:
https://codeforces.com/problemset/problem/1220/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 (
	n int
	M [][]int
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		row := ReadIntSlice(n)
		M = append(M, row)
	}

	G := make([]int, n)
	for i := 0; i < n; i++ {
		g := 0
		for j := 0; j < n; j++ {
			g = Gcd(g, M[i][j])
		}
		G[i] = g
	}
	PrintfDebug("G: %v\n", G)

	// SG := make([]int, n)
	// for i := 0; i < n; i++ {
	// 	g := 0
	// 	for j := 0; j < n; j++ {
	// 		if i == j {
	// 			continue
	// 		}
	// 		g = Gcd(g, G[j])
	// 	}
	// 	SG[i] = g
	// }

	// answers := []int{}
	// for i := 0; i < n; i++ {
	// 	answers = append(answers, G[i]/SG[i])
	// }
	// fmt.Println(PrintIntsLine(answers...))

	fmt.Println(PrintIntsLine(G...))
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	// if a <= 0 || b <= 0 {
	// 	panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	// }
	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/*********** 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"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	defer Flush()

	n := readi()
	M := make([][]int, n)
	for i := range M {
		M[i] = make([]int, n)
		for j := range M[i] {
			M[i][j] = readi()
		}
	}

	a := solve(n, M)
	sp := ""
	for _, v := range a {
		printf("%s%d", sp, v)
		sp = " "
	}
	println()
}

func solve(n int, M [][]int) []int {
	d := M[0][1]
	for i := 2; i < n; i++ {
		d = gcd(d, M[0][i])
	}

	a := make([]int, n)
	for i := 1; i*i <= d; i++ {
		if d%i != 0 {
			continue
		}
		a[0] = i
		a[1] = M[0][1] / a[0]
		a[2] = M[0][2] / a[0]
		if a[1]*a[2] == M[1][2] {
			break
		}
		a[0] = d / i
		a[1] = M[0][1] / a[0]
		a[2] = M[0][2] / a[0]
		if a[1]*a[2] == M[1][2] {
			break
		}
	}
	for i := 3; i < n; i++ {
		a[i] = M[0][i] / a[0]
	}
	return a
}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Utilities

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

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

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

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

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


You came to the exhibition and one exhibit has drawn your attention. It consists of $$$n$$$ stacks of blocks, where the $$$i$$$-th stack consists of $$$a_i$$$ blocks resting on the surface.The height of the exhibit is equal to $$$m$$$. Consequently, the number of blocks in each stack is less than or equal to $$$m$$$.There is a camera on the ceiling that sees the top view of the blocks and a camera on the right wall that sees the side view of the blocks. Find the maximum number of blocks you can remove such that the views for both the cameras would not change.Note, that while originally all blocks are stacked on the floor, it is not required for them to stay connected to the floor after some blocks are removed. There is no gravity in the whole exhibition, so no block would fall down, even if the block underneath is removed. It is not allowed to move blocks by hand either.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 100\,000$$$, $$$1 \le m \le 10^9$$$) — the number of stacks and the height of the exhibit. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le m$$$) — the number of blocks in each stack from left to right.

Print exactly one integer — the maximum number of blocks that can be removed.

NoteThe following pictures illustrate the first example and its possible solution.Blue cells indicate removed blocks. There are $$$10$$$ blue cells, so the answer is $$$10$$$.

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func main() {
	var n, m int
	fmt.Fscan(in, &n, &m)
	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	sort.Ints(a)
	ans := int64(0)
	height := 0
	for _, a := range a {
		ans += int64(a - 1)
		if height < a {
			height++
		}
	}
	fmt.Println(ans - int64(a[n-1]-height))
}

package main

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

func main(){

	buf := bufio.NewReader(os.Stdin)

	var n int
	var m int
	fmt.Fscanf(buf, "%d %d\n", &n,&m)
	mat := make([]int,n)
	var sum int64=0
	for i := 0;i < n;i++{
		fmt.Fscanf(buf,"%d",&mat[i])
		sum += int64(mat[i])
	}
	//	fmt.Printf("--%d\n",sum)
	sort.Ints(mat)
	var ans int64 = 0
	front := mat[n-1]
	for i:= n-1 ;i >= 0;i--{
		ans++
		if i > 0&&front>mat[i-1]+1{
			ans += int64(front-mat[i-1]-1)
			front = mat[i-1]
			continue
		}else if i == 0&&front > 1 {
			ans += int64(front-1)
		}
		front--
		//	fmt.Printf("i=%d ans = %d\n",mat[i],ans)
	}
	fmt.Print(sum-ans)
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.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 main() {
	defer writer.Flush()
	n, m := 0, 0
	scanf("%d %d\n", &n, &m)
	arr := make([]int, n)
	tot := int64(0)
	for i := 0; i < n; i++ {
		scanf("%d", &arr[i])
		tot += int64(arr[i])
	}
	sort.Ints(arr)

	minus := int64(0)

	cur := arr[n-1]

	for i := n - 1; i >= 0; i-- {
		if arr[i] == 0 {
			minus += int64(cur)
			cur = 0
			break
		} else {
			if cur == 0 {
				minus++
				continue
			}
			if arr[i] < cur {
				minus += int64(cur - arr[i] + 1)
				cur = arr[i] - 1
			} else {
				minus++
				cur--
			}
		}
	}
	if cur > 0 {
		minus += int64(cur)
	}
	printf("%d", tot-minus)

}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

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

func getD(num, d int) int {
	div := int(math.Pow10(d))
	return num / div % 10
}

func countSort(src []int, d int) []int {
	dst, c := make([]int, len(src)), make([]int, 10)
	for _, v := range src {
		c[getD(v, d)]++
	}
	for i := 1; i < 10; i++ {
		c[i] += c[i-1]
	}
	for i := len(src) - 1; i >= 0; i-- {
		digit := getD(src[i], d)
		index := c[digit] - 1
		dst[index], c[digit] = src[i], c[digit]-1
	}
	return dst
}

func radixSort(src []int) []int {
	for i := 0; i < 10; i++ {
		src = countSort(src, i)
	}
	return src
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := scanNum(), scanNum()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = scanNum()
	}
	b = radixSort(b)

	max, sum, needHelp := 0, int64(0), 0
	for i := 0; i < n; {
		len, extra, newSum, oldMax := 1, int64(0), int64(0), max
		for j := i + 1; j < n; j++ {
			if b[i] == b[j] {
				len++
			} else {
				break
			}
		}

		newSum, max, extra = sum+min(max, b[i]-1), b[i], min(b[i]-max-1, len-1)
		if extra >= 0 && len > 1 {
			newSum += min(max, b[i]-1)*int64(len-1) + extra
		}
		i += len

		if (max - oldMax) > len {
			needHelp += max - oldMax - 1
		} else if needHelp > 0 {
			contribution := int(min(len-(max-oldMax), needHelp))
			needHelp, newSum = needHelp-contribution, newSum+int64(contribution)
		}
		sum = newSum
	}
	fmt.Println(sum)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

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

func getD(num, d int) int {
	div := int(math.Pow10(d))
	return num / div % 10
}

func countSort(src []int, d int) []int {
	dst, c := make([]int, len(src)), make([]int, 10)
	for _, v := range src {
		c[getD(v, d)]++
	}
	for i := 1; i < 10; i++ {
		c[i] += c[i-1]
	}
	for i := len(src) - 1; i >= 0; i-- {
		digit := getD(src[i], d)
		index := c[digit] - 1
		dst[index], c[digit] = src[i], c[digit]-1
	}
	return dst
}

func radixSort(src []int) []int {
	for i := 0; i < 10; i++ {
		src = countSort(src, i)
	}
	return src
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := scanNum(), scanNum()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = scanNum()
	}
	// b = radixSort(b)
	sort.Ints(b)

	max, sum, needHelp := 0, int64(0), 0
	for i := 0; i < n; {
		len, extra, newSum, oldMax := 1, int64(0), int64(0), max
		for j := i + 1; j < n; j++ {
			if b[i] == b[j] {
				len++
			} else {
				break
			}
		}

		newSum, max, extra = sum+min(max, b[i]-1), b[i], min(b[i]-max-1, len-1)
		if extra >= 0 && len > 1 {
			newSum += min(max, b[i]-1)*int64(len-1) + extra
		}
		i += len

		if (max - oldMax) > len {
			needHelp += max - oldMax - 1
		} else if needHelp > 0 {
			contribution := int(min(len-(max-oldMax), needHelp))
			needHelp, newSum = needHelp-contribution, newSum+int64(contribution)
		}
		sum = newSum
	}
	fmt.Println(sum)
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1061/B

package main

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

func sum(a []int) int64 {
	var total int64 = 0
	for i := 0; i < len(a); i++ {
		total += int64(a[i])
	}
	return total
}

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

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

func Solve(n int, a []int) int64 {
	if n == 1 {
		return 0
	}
	sort.Ints(a)
	rows := 0
	for i := 0; i < n-1; i++ {
		if a[i] > rows {
			rows += 1
		}
	}
	blocksUsed := n - 1
	rowsMissing := a[n-1] - rows
	columnsMissing := 1
	blocksNeeded := max(rowsMissing, columnsMissing)
	return sum(a) - int64(blocksUsed+blocksNeeded)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	var m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fprintf(writer, "%d\n", Solve(n, a))
}

package main

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

func main(){

	buf := bufio.NewReader(os.Stdin)

	var n int
	var m int
	fmt.Fscanf(buf, "%d %d\n", &n,&m)
	mat := make([]int,n)
	var sum int64=0
	for i := 0;i < n;i++{
		fmt.Fscanf(buf,"%d",&mat[i])
		sum += int64(mat[i])
	}
//	fmt.Printf("--%d\n",sum)
	sort.Ints(mat)
	var ans int64 = 0
	for i:= n-2 ;i >= 0;i--{
		if mat[i+1] -mat[i] > 1 {
			ans += int64(mat[i+1] - mat[i]-1)
		}
	}
	if mat[0] > 1 {
		ans += int64(mat[0] - 1)
	}
	fmt.Print(sum-ans-int64(n))
}

package main

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

func main(){

	buf := bufio.NewReader(os.Stdin)

	var n int
	var m int
	fmt.Fscanf(buf, "%d %d\n", &n,&m)
	mat := make([]int,n)
	var sum int64=0
	for i := 0;i < n;i++{
		fmt.Fscanf(buf,"%d",&mat[i])
		sum += int64(mat[i])
	}
//	fmt.Printf("--%d\n",sum)
	sort.Ints(mat)
	var ans int64 = 0
	front := mat[n-1]
	for i:= n-1 ;i >= 0;i--{
		ans++
		if i > 0&&front>mat[i-1]+1{
			ans += int64(front-mat[i-1]-1)
			front = mat[i-1]
		}else if i == 0&&front > 1 {
			ans += int64(front-1)
		}
		front--
	//	fmt.Printf("i=%d ans = %d\n",mat[i],ans)
	}
	fmt.Print(sum-ans)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

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

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := scanNum(), scanNum()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = scanNum()
	}
	sort.Ints(b)

	max, sum := 0, int64(0)
	for i := 0; i < n; {
		len, extra := 1, int64(0)
		for j := i + 1; j < n; j++ {
			if b[i] == b[j] {
				len++
			}
		}

		sum, max, extra = sum+min(max, b[i]-1), b[i], min(b[i]-max-1, len-1)
		if extra >= 0 && len > 1 {
			sum += min(max, b[i]-1)*int64(len-1) + extra
		}
		i += len
	}

	fmt.Println(sum)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

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

func getD(num, d int) int {
	div := int(math.Pow10(d))
	return num / div % 10
}

func countSort(src []int, d int) []int {
	dst, c := make([]int, len(src)), make([]int, 10)
	for _, v := range src {
		c[getD(v, d)]++
	}
	for i := 1; i < 10; i++ {
		c[i] += c[i-1]
	}
	for i := len(src) - 1; i >= 0; i-- {
		digit := getD(src[i], d)
		index := c[digit] - 1
		dst[index], c[digit] = src[i], c[digit]-1
	}
	return dst
}

func radixSort(src []int) []int {
	for i := 0; i < 10; i++ {
		src = countSort(src, i)
	}
	return src
}

func main() {
	scanner.Split(bufio.ScanWords)
	n, _ := scanNum(), scanNum()
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = scanNum()
	}
	b = radixSort(b)

	max, sum, needHelp := 0, int64(0), 0
	for i := 0; i < n; {
		len, extra, newSum, oldMax := 1, int64(0), int64(0), max
		for j := i + 1; j < n; j++ {
			if b[i] == b[j] {
				len++
			} else {
				break
			}
		}

		newSum, max, extra = sum+min(max, b[i]-1), b[i], min(b[i]-max-1, len-1)
		if extra >= 0 && len > 1 {
			newSum += min(max, b[i]-1)*int64(len-1) + extra
		}
		i += len

		if (max - oldMax) > len {
			needHelp += max - oldMax - 1
		} else if needHelp > 0 {
			contribution := len - (max - oldMax)
			needHelp, newSum = needHelp-contribution, newSum+int64(contribution)
		}
		sum = newSum
	}
	fmt.Println(sum)
}

// URL: https://codeforces.com/problemset/problem/1061/B
// Author: sighduck

package main

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

func sum(a []int) int64 {
	var total int64 = 0
	for i := 0; i < len(a); i++ {
		total += int64(a[i])
	}
	return total
}

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

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

func Solve(n int, a []int) int64 {
	if n == 1 {
		return 0
	}
	sort.Ints(a)
	rows := min(a[n-2], n-1)
	blocksUsed := n - 1
	rowsMissing := a[n-1] - rows
	columnsMissing := 1
	blocksNeeded := max(rowsMissing, columnsMissing)
	return sum(a) - int64(blocksUsed+blocksNeeded)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	var m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fprintf(writer, "%d\n", Solve(n, a))
}


A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist.

The first line contains three integers A, B and C ( - 2·109 ≤ A, B, C ≤ 2·109) — corresponding coefficients of the line equation. It is guaranteed that A2 + B2 > 0.

If the required point exists, output its coordinates, otherwise output -1.

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

func gcd(a, b, c int64) (int64, int64, error) {
	if b == 0 {
		if c%a != 0 {
			return 0, 0, errors.New("fail")
		} else {
			return -c / a, 0, nil
		}
	}

	x, y, err := gcd(b, a%b, c)
	if err != nil {
		return 0, 0, err
	} else {
		return y, (x - a/b*y), nil
	}
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var a, b, c int64

	fmt.Fscanf(reader, "%d %d %d", &a, &b, &c)
	x, y, err := gcd(a, b, c)

	if err != nil {
		fmt.Printf("-1")
	} else {
		fmt.Printf("%d %d", x, y)
	}

}

package main

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

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

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

	var a, b, c int64
	Fscan(in, &a, &b, &c)
	c = -c
	gcd, x, y := exgcd(a, b)
	if c%gcd != 0 {
		Fprint(out, -1)
	} else {
		c /= gcd
		Fprint(out, c*x, c*y)
	}
}

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


Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer ti. The bigger this value is, the better the friendship is. No two friends have the same value ti.Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest ti.Your task is to handle queries of two types:  "1 id" — Friend id becomes online. It's guaranteed that he wasn't online before.  "2 id" — Check whether friend id is displayed by the system. Print "YES" or "NO" in a separate line. Are you able to help Limak and answer all queries of the second type?

The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 109) where ti describes how good is Limak's relation with the i-th friend. The i-th of the following q lines contains two integers typei and idi (1 ≤ typei ≤ 2, 1 ≤ idi ≤ n) — the i-th query. If typei = 1 then a friend idi becomes online. If typei = 2 then you should check whether a friend idi is displayed. It's guaranteed that no two queries of the first type will have the same idi becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type (typei = 2) so the output won't be empty.

NoteIn the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:  "1 3" — Friend 3 becomes online.  "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".  "2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".  "1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.  "1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends (t1 < t2, t3) so friend 1 won't be displayed  "2 1" — Print "NO".  "2 2" — Print "YES".  "2 3" — Print "YES".

package main

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

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n, k, q int
    fmt.Fscan(stdin, &n, &k, &q)
    t := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Fscan(stdin, &t[i])
    }

    var typ, id int
    shown := make([]int, k+1)
    ns := 0
    for i := 0; i < q; i++ {
      fmt.Fscan(stdin, &typ, &id)
      id--
      if typ == 1 { // put
        shown[ns] = id
        for j := ns; j > 0 && t[shown[j]] > t[shown[j-1]]; j-- {
          shown[j] = shown[j-1]
          shown[j-1] = id
        }
        ns = min(ns+1, k)
      } else { // check
        found := false
        for j := 0; !found && j < ns; j++ {
          if shown[j] == id {
            found = true
          }
        }
        if found {
          fmt.Println("YES")
        } else {
          fmt.Println("NO")
        }
      }
    }
}

package main

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

func main() {
	defer out.Flush()
	n := in.NextInt()
	k := in.NextInt()
	Q := in.NextInt()
	t := make([]int, n)
	for i := range t {
		t[i] = in.NextInt()
	}
	online := make([]int, 0, k+1)
	for q := 0; q < Q; q++ {
		action := in.NextInt()
		i := in.NextInt() - 1
		switch action {
		case 1:
			online = append(online, t[i])
			sort.Sort(sort.Reverse(sort.IntSlice(online)))
			if len(online) > k {
				online = online[:k]
			}
		case 2:
			ans := false
			for j := range online {
				if online[j] == t[i] {
					ans = true
					break
				}
			}
			if ans {
				fmt.Fprintln(out, "YES")
			} else {
				fmt.Fprintln(out, "NO")
			}
		}
	}
}

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

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	for len(r.buf) == 0 {
		var buf bytes.Buffer
		for {
			chunk, more, _ := r.r.ReadLine()
			buf.Write(chunk)
			if !more {
				break
			}
		}
		r.buf = buf.String()
	}
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	sign := 1
	if word[0] == '-' {
		sign = -1
		word = word[1:]
	}
	result := 0
	for i := 0; i < len(word); i++ {
		result = result*10 + int(word[i]) - '0'
	}
	result *= sign
	return result
}

// B. Bear and Displayed Friends
/*
Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t i. The bigger this value is, the better the friendship is. No two friends have the same value t i.

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest t i.

Your task is to handle queries of two types:

    "1 id" — Friend id becomes online. It's guaranteed that he wasn't online before.
    "2 id" — Check whether friend id is displayed by the system. Print "YES" or "NO" in a separate line.

Are you able to help Limak and answer all queries of the second type?

Input
The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains n integers t 1, t 2, ..., t n (1 ≤ t i ≤ 109) where t i describes how good is Limak's relation with the i-th friend.

The i-th of the following q lines contains two integers type i and id i (1 ≤ type i ≤ 2, 1 ≤ id i ≤ n) — the i-th query. If type i = 1 then a friend id i becomes online. If type i = 2 then you should check whether a friend id i is displayed.

It's guaranteed that no two queries of the first type will have the same id i becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type ( type i = 2) so the output won't be empty.

Output
For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise.

Examples
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3

Output
NO
YES
NO
YES
YES

Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3

Output
NO
YES
NO
YES

Note
In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:

    "1 3" — Friend 3 becomes online.
    "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".
    "2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".
    "1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.
    "1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends ( t 1 < t 2, t 3) so friend 1 won't be displayed
    "2 1" — Print "NO".
    "2 2" — Print "YES".
    "2 3" — Print "YES".
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	arr1 := strings.Split(strings.TrimSpace(input1), " ")
	k, _ := strconv.Atoi(arr1[1])
	q, _ := strconv.Atoi(arr1[2])

	input2, _ := reader.ReadString('\n')
	tArr := sToIArr(strings.Split(strings.TrimSpace(input2), " "))

	screen := []int{}
	for i := 0; i < q; i++ {
		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")

		typ, _ := strconv.Atoi(arr2[0])
		id, _ := strconv.Atoi(arr2[1])

		if typ == 1 {
			insertScreen(k, id, &screen, tArr)
		} else {
			if findScreen(k, id, &screen, tArr) != -1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func findScreen(k, id int, screen *[]int, tArr []int) int {
	for _, v := range *screen {
		if v == tArr[id-1] {
			return v
		}
	}
	return -1
}

func insertScreen(k, id int, screen *[]int, tArr []int) {
	if len(*screen) >= k {
		if tArr[id-1] > (*screen)[0] {
			(*screen)[0] = tArr[id-1]
		}
	} else {
		(*screen) = append(*screen, tArr[id-1])
	}
	sort.Ints((*screen))
}

func sToIArr(arr []string) (iArr []int) {
	for _, s := range arr {
		i, _ := strconv.Atoi(s)
		iArr = append(iArr, i)
	}
	return
}

// B. Bear and Displayed Friends
/*
Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t i. The bigger this value is, the better the friendship is. No two friends have the same value t i.

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest t i.

Your task is to handle queries of two types:

    "1 id" — Friend id becomes online. It's guaranteed that he wasn't online before.
    "2 id" — Check whether friend id is displayed by the system. Print "YES" or "NO" in a separate line.

Are you able to help Limak and answer all queries of the second type?

Input
The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains n integers t 1, t 2, ..., t n (1 ≤ t i ≤ 109) where t i describes how good is Limak's relation with the i-th friend.

The i-th of the following q lines contains two integers type i and id i (1 ≤ type i ≤ 2, 1 ≤ id i ≤ n) — the i-th query. If type i = 1 then a friend id i becomes online. If type i = 2 then you should check whether a friend id i is displayed.

It's guaranteed that no two queries of the first type will have the same id i becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type ( type i = 2) so the output won't be empty.

Output
For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise.

Examples
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3

Output
NO
YES
NO
YES
YES

Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3

Output
NO
YES
NO
YES

Note
In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:

    "1 3" — Friend 3 becomes online.
    "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".
    "2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".
    "1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.
    "1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends ( t 1 < t 2, t 3) so friend 1 won't be displayed
    "2 1" — Print "NO".
    "2 2" — Print "YES".
    "2 3" — Print "YES".
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	arr1 := strings.Split(strings.TrimSpace(input1), " ")
	k, _ := strconv.Atoi(arr1[1])
	q, _ := strconv.Atoi(arr1[2])

	input2, _ := reader.ReadString('\n')
	tArr := sToIArr(strings.Split(strings.TrimSpace(input2), " "))

	screen := []int{}
	for i := 0; i < q; i++ {
		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")

		typ, _ := strconv.Atoi(arr2[0])
		id, _ := strconv.Atoi(arr2[1])

		if typ == 1 {
			if len(screen) < k {
				insertScreen(k, id, &screen, tArr)
			} else {
				first := screen[0]
				if tArr[id-1] > first {
					screen[0] = tArr[id-1]
					sort.Ints(screen)
				}
			}
		} else {
			if findScreen(k, id, &screen, tArr) != -1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func findScreen(k, id int, screen *[]int, tArr []int) int {
	for _, v := range *screen {
		if v == tArr[id-1] {
			return v
		}
	}
	return -1
}

func insertScreen(k, id int, screen *[]int, tArr []int) {
	if len(*screen) > k {
		(*screen) = (*screen)[1:]
	} else {
		(*screen) = append(*screen, tArr[id-1])
		sort.Ints((*screen))
	}
}

func sToIArr(arr []string) (iArr []int) {
	for _, s := range arr {
		i, _ := strconv.Atoi(s)
		iArr = append(iArr, i)
	}
	return
}

// B. Bear and Displayed Friends
/*
Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t i. The bigger this value is, the better the friendship is. No two friends have the same value t i.

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest t i.

Your task is to handle queries of two types:

    "1 id" — Friend id becomes online. It's guaranteed that he wasn't online before.
    "2 id" — Check whether friend id is displayed by the system. Print "YES" or "NO" in a separate line.

Are you able to help Limak and answer all queries of the second type?

Input
The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains n integers t 1, t 2, ..., t n (1 ≤ t i ≤ 109) where t i describes how good is Limak's relation with the i-th friend.

The i-th of the following q lines contains two integers type i and id i (1 ≤ type i ≤ 2, 1 ≤ id i ≤ n) — the i-th query. If type i = 1 then a friend id i becomes online. If type i = 2 then you should check whether a friend id i is displayed.

It's guaranteed that no two queries of the first type will have the same id i becuase one friend can't become online twice. Also, it's guaranteed that at least one query will be of the second type ( type i = 2) so the output won't be empty.

Output
For each query of the second type print one line with the answer — "YES" (without quotes) if the given friend is displayed and "NO" (without quotes) otherwise.

Examples
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3

Output
NO
YES
NO
YES
YES

Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3

Output
NO
YES
NO
YES

Note
In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:

    "1 3" — Friend 3 becomes online.
    "2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".
    "2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".
    "1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.
    "1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends ( t 1 < t 2, t 3) so friend 1 won't be displayed
    "2 1" — Print "NO".
    "2 2" — Print "YES".
    "2 3" — Print "YES".
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	arr1 := strings.Split(strings.TrimSpace(input1), " ")
	k, _ := strconv.Atoi(arr1[1])
	q, _ := strconv.Atoi(arr1[2])

	input2, _ := reader.ReadString('\n')
	tArr := sToIArr(strings.Split(strings.TrimSpace(input2), " "))

	screen := []int{}
	for i := 0; i < q; i++ {
		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")

		typ, _ := strconv.Atoi(arr2[0])
		id, _ := strconv.Atoi(arr2[1])

		if typ == 1 {
			insertScreen(k, id, &screen, tArr)
		} else {
			if findScreen(k, id, &screen, tArr) != -1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func findScreen(k, id int, screen *[]int, tArr []int) int {
	for _, v := range *screen {
		if v == tArr[id-1] {
			return v
		}
	}
	return -1
}

func insertScreen(k, id int, screen *[]int, tArr []int) {
	if len(*screen) >= k {
		if tArr[id-1] > (*screen)[0] {
			(*screen)[0] = tArr[id-1]
		}
	} else {
		(*screen) = append(*screen, tArr[id-1])
		sort.Ints((*screen))
	}
}

func sToIArr(arr []string) (iArr []int) {
	for _, s := range arr {
		i, _ := strconv.Atoi(s)
		iArr = append(iArr, i)
	}
	return
}