package main

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

func main() {
	n := readi()
	people := make([]Person, 2*n)
	pairs := make([][2]int, n)
	for i := 0; i < n; i++ {
		a, b := read2i()
		a--
		b--
		people[a] = Person{pair: b}
		people[b] = Person{pair: a}
		pairs[i] = [2]int{a, b}
	}
	for i := 0; i < 2*n; i++ {
		dfs(people, i, 1)
	}
	for _, pair := range pairs {
		fmt.Fprintln(writer, people[pair[0]].color, people[pair[1]].color)
	}
	writer.Flush()
}

func dfs(people []Person, idx, color int) {
	if people[idx].color == 0 {
		people[idx].color = color
		reversed := ((color - 1) ^ 1) + 1
		if idx%2 == 0 {
			dfs(people, (idx+1)%len(people), reversed)
		}
		if idx%2 == 1 {
			dfs(people, (idx-1+len(people))%len(people), reversed)
		}
		dfs(people, people[idx].pair, reversed)
	}
}

type Person struct {
	color int
	pair  int
}

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

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

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

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

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

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

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func RapidReader() io.Reader {
	b, _ := ioutil.ReadAll(os.Stdin)
	return bytes.NewReader(b)
}

type Node struct {
	Adj     []*Node
	Visited bool
	Food    int
}

type Graph []Node

func (g Graph) AddEdge(x, y int) {
	g[x].Adj = append(g[x].Adj, &g[y])
}

func main() {
	reader := RapidReader()
	n := 0
	fmt.Fscan(reader, &n)

	graph := Graph(make([]Node, n*2))
	boy, girl := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &boy[i], &girl[i])
		boy[i]--
		girl[i]--
		graph.AddEdge(boy[i], girl[i])
		graph.AddEdge(girl[i], boy[i])
	}

	for i := 0; i < n; i++ {
		graph.AddEdge(i*2, (i*2+1)%(2*n))
		graph.AddEdge((i*2+1)%(2*n), i*2)
	}

	for i := 0; i < len(graph); i++ {
		if !graph[i].Visited {
			dfs(&graph[i], 1)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Println(graph[boy[i]].Food, graph[girl[i]].Food)
	}
}

func dfs(x *Node, food int) {
	x.Visited = true
	x.Food = food
	for _, y := range x.Adj {
		if !y.Visited {
			dfs(y, 3-food)
		}
	}
}

package main

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

const MAX = 200010

type Edge struct {
	u, v int
}

func addEdge(edges []Edge, First, Next []int, x, y, cnt int) {

	edges[cnt].u = x
	edges[cnt].v = y
	Next[cnt] = First[x]
	First[x] = cnt

}

func match(edges []Edge, First, Next, res []int, root int) {

	for j := First[root]; j != -1; j = Next[j] {
		t := edges[j].v
		if res[t] == 0 {
			if res[root] == 1 {
				res[t] = 2
			} else {
				res[t] = 1
			}
			match(edges, First, Next, res, t)
		}
	}

}

func main() {

	var n, cnt int
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)

	fmt.Fscanf(r, "%d\n", &n)

	edges := make([]Edge, 4*n+1)
	First := make([]int, n*2+1)
	Next := make([]int, n*4+1)
	res := make([]int, n*2+1)
	lx := make([]int, n+1)
	rx := make([]int, n+1)

	for i := 1; i <= 2*n; i++ {
		First[i] = -1
		res[i] = 0
	}

	cnt = 0
	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d %d\n", &lx[i], &rx[i])
		cnt++
		addEdge(edges, First, Next, lx[i], rx[i], cnt)
		cnt++
		addEdge(edges, First, Next, rx[i], lx[i], cnt)
		cnt++
		addEdge(edges, First, Next, 2*i-1, 2*i, cnt)
		cnt++
		addEdge(edges, First, Next, 2*i, 2*i-1, cnt)

	}

	/*
			fmt.Printf("n = %d, cnt = %d\n", n, cnt)

			for i := 1; i <= 2*n; i++ {
				fmt.Printf("i = %d: ", i)
				for j := First[i]; j != -1; j = Next[j] {
					fmt.Printf("%d ", edges[j].v)
				}
				fmt.Printf("\n")
			}

		res[1] = 1
		match(1)
	*/

	for i := 1; i <= 2*n; i++ {
		if res[i] == 0 {
			res[i] = 1
			match(edges, First, Next, res, i)
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d %d\n", res[lx[i]], res[rx[i]])
	}

}

package main

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

const MAX = 400010

type Edge struct {
	u, v int64
}

var edges []Edge
var First, Next, res, lx, rx []int64
var cnt int64

func init_func() {
	edges = make([]Edge, MAX)
	First = make([]int64, MAX)
	Next = make([]int64, MAX)
	res = make([]int64, MAX)
	lx = make([]int64, MAX)
	rx = make([]int64, MAX)

	for i := 0; i < MAX; i++ {
		First[i] = -1
		Next[i] = -1
		res[i] = 0
	}

	cnt = 0
}

func addEdge(x, y int64) {
	cnt++
	edges[cnt].u = x
	edges[cnt].v = y
	Next[cnt] = First[x]
	First[x] = cnt
}

var n int64

func match(root int64) {

	for j := First[root]; j != -1; j = Next[j] {
		t := edges[j].v
		if res[t] == 0 {
			if res[root] == 1 {
				res[t] = 2
			} else {
				res[t] = 1
			}
			match(t)
		}
	}

}

func main() {

	init_func()
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)

	fmt.Fscanf(r, "%v\n", &n)

	for i := int64(1); i <= n; i++ {
		fmt.Fscanf(r, "%v %v\n", &lx[i], &rx[i])
		addEdge(lx[i], rx[i])
		addEdge(rx[i], lx[i])
		addEdge(2*i-1, 2*i)
		addEdge(2*i, 2*i-1)
	}
	/*
			fmt.Printf("n = %d, cnt = %d\n", n, cnt)

			for i := 1; i <= 2*n; i++ {
				fmt.Printf("i = %d: ", i)
				for j := First[i]; j != -1; j = Next[j] {
					fmt.Printf("%d ", edges[j].v)
				}
				fmt.Printf("\n")
			}

		res[1] = 1
		match(1)
	*/

	for i := int64(1); i <= 2*n; i++ {
		if res[i] == 0 {
			res[i] = 1
			match(i)
		}
	}

	for i := int64(1); i <= n; i++ {
		fmt.Printf("%v %v\n", res[lx[i]], res[rx[i]])
	}

}

package main

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

func solve() {
    n := readInt()
    a := make([][]int, 2*n)
    order := make([]int, 2*n)
    for i := 0; i < n; i++ {
        l, r := 2*i, 2*i+1
        a[l] = append(a[l], r)
        a[r] = append(a[r], l)
        u, v := readInt()-1, readInt()-1
        order[l], order[r] = u, v
        a[u] = append(a[u], v)
        a[v] = append(a[v], u)
    }

    was, ans := make([]bool, 2*n), make([]int, 2*n)
    for v := range a {
        if was[v] {
            continue
        }
        q, val := []int{v}, 0
        was[v] = true
        for len(q) > 0 {
            c := q[len(q)-1]
            q = q[:len(q)-1]
            ans[c], val = val, (val+1)%2
            for _, u := range a[c] {
                if !was[u] {
                    was[u] = true
                    q = append(q, u)
                    break
                }
            }
        }
    }

    for i := 0; i < len(order); i += 2 {
        for j := i; j <= i+1; j++ {
            fmt.Print(ans[order[j]]+1, " ")
        }
        fmt.Println()
    }
}

// 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 (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	n := readi()
	people := make([]Person, 2*n)
	pairs := make([][2]int, n)
	for i := 0; i < n; i++ {
		a, b := read2i()
		a--
		b--
		people[a] = Person{pair: b}
		people[b] = Person{pair: a}
		pairs[i] = [2]int{a, b}
	}
	for i := 0; i < n; i++ {
		dfs(people, i, 1)
	}
	for _, pair := range pairs {
		fmt.Fprintln(writer, people[pair[0]].color, people[pair[1]].color)
	}
	writer.Flush()
}

func dfs(people []Person, idx, color int) {
	if people[idx].color == 0 {
		people[idx].color = color
		reversed := ((color - 1) ^ 1) + 1
		if idx%2 == 0 {
			dfs(people, (idx+1)%len(people), reversed)
		}
		if idx%2 == 1 {
			dfs(people, (idx-1+len(people))%len(people), reversed)
		}
		dfs(people, people[idx].pair, reversed)
	}
}

type Person struct {
	color int
	pair  int
}

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

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

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

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

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

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

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func main() {
	n := readi()
	people := make([]Person, 2*n)
	pairs := make([][2]int, n)
	for i := 0; i < n; i++ {
		a, b := read2i()
		a--
		b--
		people[a] = Person{pair: b}
		people[b] = Person{pair: a}
		pairs[i] = [2]int{a, b}
	}
	for i := 0; i < n; i++ {
		dfs(people, i, 1)
	}
	for _, pair := range pairs {
		fmt.Fprintln(writer, people[pair[0]].color, people[pair[1]].color)
	}
	writer.Flush()
}

func dfs(people []Person, idx, color int) {
	if people[idx].color == 0 {
		people[idx].color = color
		reversed := ((color - 1) ^ 1) + 1
		if idx%2 == 0 && idx+1 < len(people) && people[idx+1].color == 0 {
			dfs(people, idx+1, reversed)
		}
		if idx%2 == 1 && idx-1 >= 0 && people[idx-1].color == 0 {
			dfs(people, idx-1, reversed)
		}
		dfs(people, people[idx].pair, reversed)
	}
}

type Person struct {
	color int
	pair  int
}

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

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

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

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

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

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

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func RapidReader() io.Reader {
	b, _ := ioutil.ReadAll(os.Stdin)
	return bytes.NewReader(b)
}

type Node struct {
	Adj     []*Node
	Visited bool
	Food    int
}

type Graph []Node

func (g Graph) AddEdge(x, y int) {
	g[x].Adj = append(g[x].Adj, &g[y])
}

func main() {
	reader := RapidReader()
	n := 0
	fmt.Fscan(reader, &n)

	graph := Graph(make([]Node, n*2))
	boy, girl := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &boy[i], &girl[i])
		boy[i]--
		girl[i]--
		graph.AddEdge(boy[i], girl[i])
		graph.AddEdge(girl[i], boy[i])
	}

	for i := 0; i < n; i++ {
		graph.AddEdge(i*2, (i*2+1)%(2*n))
		graph.AddEdge((i*2+1)%(2*n), i*2)
	}

	dfs(&graph[0], 1)
	for i := 0; i < n; i++ {
		fmt.Println(graph[boy[i]].Food, graph[girl[i]].Food)
	}
}

func dfs(x *Node, food int) {
	x.Visited = true
	x.Food = food
	for _, y := range x.Adj {
		if !y.Visited {
			dfs(y, 3-food)
		}
	}
}

package main

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

func RapidReader() io.Reader {
	b, _ := ioutil.ReadAll(os.Stdin)
	return bytes.NewReader(b)
}

type Node struct {
	Adj     []*Node
	Visited bool
	Food    int
}

type Graph []Node

func (g Graph) AddEdge(x, y int) {
	g[x].Adj = append(g[x].Adj, &g[y])
}

func main() {
	reader := RapidReader()
	n := 0
	fmt.Fscan(reader, &n)

	graph := Graph(make([]Node, n*2))
	boy, girl := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &boy[i], &girl[i])
		boy[i]--
		girl[i]--
		graph.AddEdge(boy[i], girl[i])
		graph.AddEdge(girl[i], boy[i])
	}

	for i := 0; i < n; i++ {
		graph.AddEdge(i*2, (i*2+1)%(2*n))
		graph.AddEdge((i*2+1)%(2*n), i*2)
	}

	for i := 0; i < n; i++ {
		if !graph[i].Visited {
			dfs(&graph[i], 1)
		}
	}

	for i := 0; i < n; i++ {
		fmt.Println(graph[boy[i]].Food, graph[girl[i]].Food)
	}
}

func dfs(x *Node, food int) {
	x.Visited = true
	x.Food = food
	for _, y := range x.Adj {
		if !y.Visited {
			dfs(y, 3-food)
		}
	}
}

package main

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

const MAX = 200010

type Edge struct {
	u, v int
}

func addEdge(edges []Edge, First, Next []int, x, y, cnt int) {
	fmt.Printf("x = %d, y = %d\n", x, y)
	edges[cnt].u = x
	edges[cnt].v = y
	Next[cnt] = First[x]
	First[x] = cnt

}

func match(edges []Edge, First, Next, res []int, root int) {

	for j := First[root]; j != -1; j = Next[j] {
		t := edges[j].v
		if res[t] == 0 {
			if res[root] == 1 {
				res[t] = 2
			} else {
				res[t] = 1
			}
			match(edges, First, Next, res, t)
		}
	}

}

func main() {

	var n, cnt int
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)

	fmt.Fscanf(r, "%d\n", &n)

	edges := make([]Edge, 4*n+1)
	First := make([]int, n*2+1)
	Next := make([]int, n*4+1)
	res := make([]int, n*2+1)
	lx := make([]int, n+1)
	rx := make([]int, n+1)

	for i := 1; i <= 2*n; i++ {
		First[i] = -1
		res[i] = 0
	}

	cnt = 0
	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d %d\n", &lx[i], &rx[i])
		cnt++
		addEdge(edges, First, Next, lx[i], rx[i], cnt)
		cnt++
		addEdge(edges, First, Next, rx[i], lx[i], cnt)
		cnt++
		addEdge(edges, First, Next, 2*i-1, 2*i, cnt)
		cnt++
		addEdge(edges, First, Next, 2*i, 2*i-1, cnt)

	}

	fmt.Printf("cnt = %d\n", cnt)
	/*
			fmt.Printf("n = %d, cnt = %d\n", n, cnt)

			for i := 1; i <= 2*n; i++ {
				fmt.Printf("i = %d: ", i)
				for j := First[i]; j != -1; j = Next[j] {
					fmt.Printf("%d ", edges[j].v)
				}
				fmt.Printf("\n")
			}

		res[1] = 1
		match(1)
	*/

	for i := 1; i <= 2*n; i++ {
		if res[i] == 0 {
			res[i] = 1
			match(edges, First, Next, res, i)
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d %d\n", res[lx[i]], res[rx[i]])
	}

}

package main

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

const MAX = 20010

type Edge struct {
	u, v int
}

var edges []Edge
var First, Next, res, lx, rx []int
var cnt int

func init_func() {
	edges = make([]Edge, MAX)
	First = make([]int, MAX)
	Next = make([]int, MAX)
	res = make([]int, MAX)
	lx = make([]int, MAX)
	rx = make([]int, MAX)

	for i := 0; i < MAX; i++ {
		First[i] = -1
		Next[i] = -1
		res[i] = 0
	}

	cnt = 0
}

func addEdge(x, y int) {
	cnt++
	edges[cnt].u = x
	edges[cnt].v = y
	Next[cnt] = First[x]
	First[x] = cnt
}

var n int

func match(root int) {

	for j := First[root]; j != -1; j = Next[j] {
		t := edges[j].v
		if res[t] == 0 {
			if res[root] == 1 {
				res[t] = 2
			} else {
				res[t] = 1
			}
			match(t)
		}
	}

}

func main() {

	init_func()
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)

	fmt.Fscanf(r, "%d\n", &n)

	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d %d\n", &lx[i], &rx[i])
		addEdge(lx[i], rx[i])
		addEdge(rx[i], lx[i])
		addEdge(2*i-1, 2*i)
		addEdge(2*i, 2*i-1)
	}

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

	for i := 1; i <= 2*n; i++ {
		fmt.Printf("i = %d: ", i)
		for j := First[i]; j != -1; j = Next[j] {
			fmt.Printf("%d ", edges[j].v)
		}
		fmt.Printf("\n")
	}

	res[1] = 1
	match(1)
	/*
		for i := 1; i <= 2*n; i++ {
			if res[i] == 0 {
				res[i] = 1
				match(i)
			}
		}
	*/

	for i := 1; i <= n; i++ {
		fmt.Printf("%d %d\n", res[lx[i]], res[rx[i]])
	}

}

package main

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

const MAX = 20010

type Edge struct {
	u, v int
}

var edges []Edge
var First, Next, res []int
var cnt int

func init_func() {
	edges = make([]Edge, MAX)
	First = make([]int, MAX)
	Next = make([]int, MAX)
	res = make([]int, MAX)

	for i := 0; i < MAX; i++ {
		First[i] = -1
		Next[i] = -1
		res[i] = 0
	}

	cnt = 0
}

func addEdge(x, y int) {
	cnt++
	edges[cnt].u = x
	edges[cnt].v = y
	Next[cnt] = First[x]
	First[x] = cnt
}

var n int

func match(root int) {
	if res[root] == 1 {
		for j := First[root]; j != -1; j = Next[j] {
			tmp := edges[j].v
			if res[tmp] == 0 {
				res[tmp] = 2
				match(tmp)
			}
		}
	} else {
		for j := First[root]; j != -1; j = Next[j] {
			tmp := edges[j].v
			if res[tmp] == 0 {
				res[tmp] = 1
				match(tmp)
			}
		}
	}

}

func main() {

	init_func()
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)

	var x, y int

	fmt.Fscanf(r, "%d\n", &n)

	for i := 1; i <= n; i++ {
		fmt.Fscanf(r, "%d %d\n", &x, &y)
		addEdge(x, y)
		addEdge(y, x)
		addEdge(2*i-1, 2*i)
		addEdge(2*i, 2*i-1)
	}

	/*
		fmt.Printf("n = %d, cnt = %d\n", n, cnt)

		for i := 1; i <= n; i++ {
			fmt.Printf("i = %d: ", i)
			for j := First[i]; j != -1; j = Next[j] {
				fmt.Printf("%d ", edges[j].v)
			}
			fmt.Printf("\n")
		}

	*/
	res[1] = 1
	match(1)

	for i := 1; i <= n; i++ {
		x, y := edges[i].u, edges[i].v
		fmt.Printf("%d %d\n", res[x], res[y])
	}

}


package main
import "fmt"
func main() {
	var n int
	var last, sum, temp, flag int
	fmt.Scan(&n)
	last=-1;
	sum=0;
	temp=0;
	flag=0;
	for i:=1; i<=n; i++ {
		var x int
		fmt.Scan(&x)
		if(x!=last) {
			if(last==-1) {
				last=x;
			}else if(sum==0) {
				sum=temp;
				last=x;
			}else {
				if(sum!=temp) {
				    flag=1;
				}
			}
			last=x;
			temp=1;
		}else {
		temp=temp+1;
		}
	}
	if(sum!=temp&&sum!=0) {
	    flag=1;
	}
	if(flag==1) {
	    fmt.Println("NO")
	}else {
	    fmt.Println("YES")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var x[100005] int
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
		}
    var r int64
    r = 1
    var l int64
    l = -1
    for i:= 1; i<n; i++{
        if(x[i]==x[i-1]){
            r+=1
        } else{
            if((l==r) || (l==-1)){
                l = r
                r = 1
            }else{
                fmt.Println("NO")
                return
            }
        }
    }

    if(r == l || l ==-1){
    fmt.Println("Yes")
    }else{
    fmt.Print("NO")
    }
}
///SAliB :)

package main

import "fmt"

func main() {

    var n int
    fmt.Scan(&n)

    var ara [100005]int

    for i := 0; i < n; i++ {
        fmt.Scan(&ara[i])
    }

    var p int = 1
    var q int = -1
    var ans bool = true

    for i := 1; i < n; i++ {

        if ara[i] != ara[i-1] {
            if q != -1 && p != q {
                ans = false
            }else {
                q = p
                p = 1
            }

        }else {
            p++
        }
    }
    if q != -1 && p != q {
        ans = false
    }

    if ans {
        fmt.Printf("YES")
    }else {
        fmt.Printf("NO")
    }
}

package main

import "fmt"
import "os"

func fail(){
	fmt.Println("NO")
	os.Exit(0)
}

func main(){
	var n int
	fmt.Scan(&n)
	var fi = false
	var l = -1
	var cur = 0
	var se = false
	var ans = 0
	for i := 0; i < n; i++ {
		var b int
		fmt.Scan(&b)
		if(!fi) {
			fi = true
			cur = 1
		}else{
			if(l == b) {
				cur += 1;
			}else{
				if(se) {
					if(ans != cur) { fail() }
				}else{
					se = true
					ans = cur
				}
				cur = 1
			}
		}
		l = b
	}
	if(se && ans != cur) { fail() }
	fmt.Println("YES")
}

package main

import "fmt"

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

    if sum == n {
        fmt.Println("YES")
        return
    }
    if sum == 0 {
        fmt.Println("YES")
        return
    }

    var len, mLen int
    len = 1
    mLen = -1
    for i := 1; i < n; i++ {
        if !(aa[i] == aa[i-1]) {
            if !(mLen == -1) {
                if !(len == mLen) {
                    fmt.Println("NO")
                    return
                }
            }
            if mLen == -1 {
                mLen = len
            }
            len = 1
        }
        if aa[i] == aa[i-1] {
            len++
        }
    }
    if !(len == mLen) {
        fmt.Println("NO")
        return
    }

    fmt.Println("YES")

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var x int
	fmt.Scan(&x)
	last := x
	cnt := 1
	answer := 1
	cnt1 := 0
	q := -1
	for i := 1; i < n; i++ {
		fmt.Scan(&x)
		if x != last{
		    if cnt != cnt1{
		        if(q != -1){
		        answer = 0
		        }
		    }
		    if(q==-1){
		        cnt1 = cnt
		        last = x
		        cnt = 1
		        q = 1
		    }else{
		        last = x
		        cnt = 1
		    }

		}else{
		    cnt = cnt + 1
		}
	}
//	fmt.Printf(" %d %d",cnt,q);
	        if q != -1{
	        if cnt != cnt1{
	            answer = 0
	        }
	    }
	if answer == 1{
	fmt.Printf("YES")
	} else {
	  fmt.Printf("NO")
	}
}

package main

import "fmt"

func main(){
	var n , ans int
	ans = 0
	var lasti int
	fmt.Scan(&n)
	fmt.Scan(&lasti)
	var blockSize , currentBlock int
	blockSize = -1
	currentBlock = 1
	for i := 1 ; i < n ; i++ {
		var x int
		fmt.Scan(&x)

		if x == lasti{

			currentBlock++
		}else{
			if blockSize == -1{
				blockSize = currentBlock
			}else if blockSize != currentBlock{
				ans = -1
			}
			currentBlock = 1
			lasti = x
		}
	}

	if blockSize != currentBlock && blockSize != -1 && currentBlock != 0{
		ans = -1
	}
	if ans == -1{
		fmt.Println("NO")
	}else{
		fmt.Println("YES")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var a[100005] int
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		}
    var sec int64
    sec = 1
    var last int64
    last = -1
    for i:= 1; i<n; i++{
        if(a[i]==a[i-1]){
            sec+=1
        } else{
            if((last==sec) || (last==-1)){
                last = sec
                sec = 1
            }else{
                fmt.Println("NO")
                return
            }
        }
    }

    if(sec == last || last ==-1){
    fmt.Println("Yes")
}else{
    fmt.Print("NO")
}
	}

package main

import "fmt"

var n int
var a [100010]int

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var len = 1
	for i := 1; i < n; i++ {
		if a[i] == a[i - 1]{
			len += 1
		} else {break}
	}

	if n % len > 0{
		fmt.Println("NO")
	} else{
	    var fc = a[0]
		var g = true
		for i := len; i < n; i += len{
		    var cc = a[i]
		    if fc == cc{
		        g = false
		    }
			for j := i + 1; j < i + len; j++{
				if a[j] != a[j-1]{
					g = false
				}
			}
			fc = 1 - fc
		}
		if g == true{
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main;
import (
    "fmt"
    "os"
    "bufio"
)
var (
    n int
    a [222222]int
)

func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	var last = -1
	var cur = -2
	var lngth = 0
	var ii = -1
	for i := 0; i <= n; i++ {
		if i < n {
	        fmt.Fscan(in, &cur)
		} else { cur = -1 }
		if(last != cur) {
		    ii++
		    a[ii] = lngth
		    lngth = 0
		}
		lngth++
		last = cur
	}
    var suka = a[1]
    var ans = 1
	for i := 1; i <= ii; i++ {
	    if a[i] != suka { ans = 0 }
		//fmt.Printf("%d %d\n", a[i], ans)
	}
    if ans == 1 {
        fmt.Printf("YES")
    } else {
        fmt.Printf("NO")
    }

}

package main

import "fmt"

func main() {
	var n, tek, pred, kol, pos int
	fmt.Scan(&n)
	fmt.Scan(&pred)
	pos = 0
	kol = 1
	a := make([]int, n, n)
	for i := 0; i < n - 1; i++ {
		fmt.Scan(&tek)
		if tek != pred {
		    a[pos] = kol
		    pos = pos + 1
		    kol = 1
		} else {
		    kol = kol + 1
		}
		pred = tek
	}
	a[pos] = kol
	pos = pos + 1
	var ch int
	var ans bool
	ans = true
	ch = 0
	for i := 0; i < pos; i++ {
	    if (ch == 0 && a[i] > 0) {
	        ch = a[i]
	        continue
	    }
	    if a[i] != ch {
	        ans = false;
	    }
	}
	if !ans {
	    fmt.Println("NO")
	} else {
	    fmt.Println("YES")
	}
}

package main

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

const N = 100005
var n int
var a[N] int

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

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

	var sz = 0
	var dt = make([]int, 0)
	for i := 0; i < n; i++ {
		sz++
		if i == n - 1 || a[i] != a[i + 1] {
			dt = append(dt, sz)
			sz = 0
		}
	}

	sort.Ints(dt)
	for i := 0; i < len(dt) - 1; i++ {
		if dt[i] != dt[i + 1] {
			fmt.Fprintf(writer, "NO")
			return
		}
	}

	fmt.Fprintf(writer, "YES")
}

package main
 import   "fmt"

func main(){
	var n int
	fmt.Scanf("%d\n", &n)
	var arr[100002] int
	var b[100002] int

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	w := 1
	for i := 0; i+1 < n; i++ {
		if arr[i] == arr[i+1] {
			w += 1
		} else {
			break
		}
	}
	ans := true

	if(w == 0 || n % w != 0){
	    ans = false
	}else{
        for j:=0; j < n/w; j++ {
            o := 0
        	z := 0
        	for i := 0; i < w; i++ {
        	    if(arr[i + j*w] == 1){
        	        o ++
        	    }else{
        	        z ++
        	    }
        	}
        	b[j] = o;
        	if(!(o == w || z == w)){
        	    ans = false
        	}
        	if(j > 0 && (b[j] == b[j-1])){
        	    ans = false
        	}
        }
	}
    if(ans){
        fmt.Print("YES")
    }else{
        fmt.Print("NO")
    }
}

package main
import "fmt"
import "os"

func main() {
   var n int
   b := 0
   a := 0
   fmt.Scan(&n)
   var flag bool = false
   for n > 0 {
	n--;
	var m int
	fmt.Scan(&m)

	if m > 0 {

		if flag {
			a++
		} else {
			flag = !flag
			if !(a == 0 || b == 0) {
				if a != b {
					fmt.Println("NO")
					os.Exit(0)
				}
				a = 0
			}
			a++
		}
	} else {
		if !flag {
			b++
		} else {
			flag = !flag
			if !(a == 0 || b == 0) {
				if a != b {
					fmt.Println("NO")
					os.Exit(0)
				}
				b = 0
			}
			b++
		}
	}

   }
   	if !(a == 0 || b == 0) {
		if a != b {
			fmt.Println("NO")
			os.Exit(0)
		}
	}
	fmt.Println("YES")
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	i := 0
	j := 1
	for (j < n && a[i] == a[j]) {
	    j++
	}
	len := j - i;
	j++
	var good string
	good = "YES"
	for i = j - 1; i < n; i = j - 1 {
	    for j < n && a[i] == a[j] {
	        j++
	    }
	    if (j - i != len) {
	        good = "NO"
	    }
	    j++
	}
	fmt.Println(good)
}

package main

import "fmt"

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

	count := 0
	mx := 0
	ok := 1

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if i== 0 {
		    count++;
		}else {
		    if a[i - 1] != a[i] {
		        if mx == 0 {
		            mx = count
		        }else {
		            if mx != count {
		                ok = 0;
		            }
		        }
		        count = 1
		    }else {
		        count++;
		    }
		}
	}
    if mx == 0 {
        mx = count
    }else {
        if mx != count {
            ok = 0;
        }
    }

    if ok == 0 {
	    fmt.Println("NO")
    }else {
        fmt.Println("YES")
    }
}

package main

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

func main() {
	out := bufio.NewWriter(os.Stdout)
    ints := getInts()
    _, xs := ints[0], ints[1:]
	current := xs[0];
	currentLen := 0
	prevLen := 0
	result := true
	for _, num := range xs {
		if num != current {
			if prevLen == 0 {
				prevLen = currentLen
			} else if prevLen != currentLen {
				result = false
			}
			current = num
			currentLen = 0
		}
        // fmt.Print(current, currentLen, prevLen, result, "\n")
		currentLen += 1
	}
    if prevLen != 0 && result {
        result = prevLen == currentLen
    }
	if result {
		out.WriteString("YES\n")
		out.Flush()
	} else {
		out.WriteString("NO\n")
		out.Flush()
	}
}

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

package main

import "fmt"
import "os"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n, n)
	var flag int
	flag = 0
	var c int
	c = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	flag = a[0]
	for i := 0; i < n; i++{
		if a[i] == a[0]{
			c++
		} else {
			break
		}
	}
	var cur int
	cur = 0
	for j := 0; j < n; j++ {
		if a[j] == flag {
			cur = cur + 1
		} else {
			if cur != c {
				fmt.Println("NO")
				os.Exit(0)
			} else {
				flag = 1 - flag
				cur = 1
			}
		}
	}
	if cur == c {
	fmt.Println("YES")
	} else {
	fmt.Println("NO")
	}
}

package main

import (
	"fmt"
)

    var(
        now int
        lst int
        len int
        n int
        i int
        all int
        flag int
    )

func main(){

    fmt.Scanf("%d\n",&n)
    now=0
    lst=0
    all=0
    for i=1;i<=n;i++{
        fmt.Scanf("%d",&now)
     //   fmt.Printf("%d\n",now);
        if lst!=now{
            if len==0 {
                len=all
                all=0
            }else {
                if len!=all{
                    if flag==0{
                  //  fmt.Printf("%d %d %d",i,len,all)
                    fmt.Printf("NO");
                    flag=1;
                    }
                }
                all=0;
            }
        }
        all=all+1
        lst=now
    }
    if(len!=all&&len!=0&&flag==0){
            fmt.Printf("NO");
            flag=1;
    }
    if flag==0{
    fmt.Printf("YES")
    }
}

package main

import "fmt"

func main() {
	var n, last, x, ans, lastcnt, cnt int
        ans = 1
        lastcnt =0
	fmt.Scan(&n)
        fmt.Scan(&last)
        cnt =1
	for i := 1; i < n; i++ {
		fmt.Scan(&x)
		if x != last {
                  last=x
                  if lastcnt == 0 {
                    lastcnt= cnt
                    cnt=1
                  } else {
                    if lastcnt != cnt {
                       ans= 0

                    }
                    cnt=1
                  }
                } else {
                  cnt++
                }
	}
        if lastcnt != cnt && lastcnt != 0 {
           ans= 0
        }
		if ans == 0 {
			fmt.Println("NO")
		} else {
			fmt.Printf("YES")
		}
}

package main
import "fmt"

func main() {
    var n, prev, curr_len, each, input int
    fmt.Scanf("%d\n", &n)
    fmt.Scanf("%d", &prev)
    curr_len = 1
    each = -1000
    for i := 0; i < n - 1; i++  {
        fmt.Scanf("%d", &input)
        if (input == prev) {
            curr_len++
        } else {
            if (each == -1000) {
                each = curr_len
                curr_len = 1
            } else {
                if (curr_len != each) {
                    fmt.Println("NO")
                    return
                } else {
                    curr_len = 1
                }
            }
        }
        prev = input
    }
    if (each != -1000 && curr_len != each) {
        fmt.Println("NO")
    } else {
        fmt.Println("YES")
    }
}

package main

import (
	"bufio"
	"io/ioutil"
	"os"
)

func main() {
	out := bufio.NewWriter(os.Stdout)
    in := bufio.NewReader(os.Stdin)
    in.ReadString('\n');
	xs, _ := in.ReadString('\n')
	current := '-';
	currentLen := 0
	prevLen := 0
	result := true
	for _, num := range xs {
        if num == ' ' {
            continue
        }
        if current == '-' {
            current = num
        }
		if num != current {
			if prevLen == 0 {
				prevLen = currentLen
			} else if prevLen != currentLen {
				result = false
			}
			current = num
			currentLen = 0
		}
		currentLen += 1
	}
	if result {
		out.WriteString("YES\n")
		out.Flush()
	} else {
		out.WriteString("NO\n")
		out.Flush()
	}
}

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

package main

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

func main() {
	out := bufio.NewWriter(os.Stdout)
    ints := getInts()
    _, xs := ints[0], ints[1:]
	current := xs[0];
	currentLen := 0
	prevLen := 0
	result := true
	for _, num := range xs {
		if num != current {
			if prevLen == 0 {
				prevLen = currentLen
			} else if prevLen != currentLen {
				result = false
			}
			current = num
			currentLen = 0
		}
        // fmt.Print(current, currentLen, prevLen, result, "\n")
		currentLen += 1
	}
    if prevLen != 0 {
        result = prevLen == currentLen
    }
	if result {
		out.WriteString("YES\n")
		out.Flush()
	} else {
		out.WriteString("NO\n")
		out.Flush()
	}
}

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

package main

import "fmt"

var n int
var a [100010]int

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var len = 1
	for i := 1; i < n; i++ {
		if a[i] == a[i - 1]{
			len += 1
		} else {break}
	}

	if n % len > 0{
		fmt.Println("NO")
	} else{
		var g = true
		for i := len; i < n; i += len{
			for j := i + 1; j < i + len; j++{
				if a[j] != a[j-1]{
					g = false
				}
			}
		}
		if g == true{
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main
 import   "fmt"

func main(){
	var n int
	fmt.Scanf("%d\n", &n)
	var arr[100002] int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	w := 1
	for i := 0; i+1 < n; i++ {
		if arr[i] == arr[i+1] {
			w += 1
		} else {
			break
		}
	}
	ans := true

	if(w == 0 || n % w != 0){
	    ans = false
	}else{
        for j:=0; j < n/w; j++ {
            o := 0
        	z := 0
        	for i := 0; i < w; i++ {
        	    if(arr[i + j*w] == 1){
        	        o ++
        	    }else{
        	        z ++
        	    }
        	}
        	if(!(o == w || z == w)){
        	    ans = false
        	}
        }
	}
    if(ans){
        fmt.Print("YES")
    }else{
        fmt.Print("NO")
    }
}

package main
import "fmt"

func main() {
    var n, prev, curr_len, each, input int
    fmt.Scanf("%d\n", &n)
    fmt.Scanf("%d", &prev)
    curr_len = 1
    each = -1000
    for i := 0; i < n - 1; i++  {
        fmt.Scanf("%d", &input)
        if (input == prev) {
            curr_len++
        } else {
            if (each == -1000) {
                each = curr_len
                curr_len = 1
            } else {
                if (curr_len != each) {
                    fmt.Println("NO")
                    return
                }
            }
        }
        prev = input
        if (each != -1000 && curr_len > each) {
                    fmt.Println("NO")
                    return
                }
    }
    fmt.Println("YES")
}

package main
import "fmt"

func main() {
    var n, prev, curr_len, each, input int
    fmt.Scanf("%d\n", &n)
    fmt.Scanf("%d", &prev)
    curr_len = 1
    each = -1000
    for i := 0; i < n - 1; i++  {
        fmt.Scanf("%d", &input)
        if (input == prev) {
            curr_len++
        } else {
            if (each == -1000) {
                each = curr_len
                curr_len = 1
            } else {
                if (curr_len != each) {
                    fmt.Println("NO")
                    return
                } else {
                    curr_len = 1
                }
            }
        }
        prev = input
    }
    if (each != -1000 && curr_len > each) {
        fmt.Println("NO")
    } else {
        fmt.Println("YES")
    }
}

package main
import "fmt"
func main() {
	var n int
	var last, sum, temp, flag int
	fmt.Scan(&n)
	last=-1;
	sum=0;
	temp=0;
	flag=0;
	for i:=1; i<=n; i++ {
		var x int
		fmt.Scan(&x)
		if(x!=last) {
			if(last==-1) {
				last=x;
			}else if(sum==0) {
				sum=temp;
				last=x;
			}else {
				if(sum!=temp) {
				    flag=1;
				}
			}
			last=x;
			temp=1;
		}else {
		temp=temp+1;
		}
	}
	if(sum!=temp&&sum!=0) {
	    flag=1;
	}
	if(flag==1) {
	    fmt.Println("NO")
	}else {
	    fmt.Println(sum,"YES")
	}
}


package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]byte, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		s := string(a)
		i, j := strings.IndexByte(s, 1), strings.LastIndexByte(s, 1)
		s = s[i:j]
		c := 0
		for _, b := range s {
			if b ==0{
				c++
			}
		}
		Fprintln(out, c)

		return
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}
}

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

package main

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

var (
	t     int
	n     int
	ones  int
	first int
)

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

	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)

		a := make([]int, n)
		var b []int

		ones = 0
		for i := range a {
			fmt.Fscan(reader, &a[i])
			b = append(b, a[i])
			if a[i] == 1 {
				ones++
				if ones == 1 {
					first = i
				}
			}
		}

		left := moveToLeft2(a, n, ones, first)

		/*right := moveToRight(b, n, ones)

		if right >= left {
			fmt.Println(left)
		} else {
			fmt.Println(right)
		}*/

		fmt.Println(left)
	}
}

func moveToLeft(a []int, n int, ones int) int {

	var index int = 0
	step := 0

	for index < n {
		if a[index] == 1 {
			index++
		} else {
			for a[index] != 1 {
				for j := index + 1; j < n; j++ {
					temp := a[j-1]
					a[j-1] = a[j]
					a[j] = temp
				}
				//printArr(a)
				step++
			}
			index++
		}
		if index == ones {
			break
		}
	}

	return step
}

func moveToLeft2(a []int, n int, ones int, first int) int {

	var index int = first
	step := 0
	count := 0

	for index < n {
		if a[index] == 1 {
			count++
			index++
		} else {
			for a[index] != 1 {
				for j := index + 1; j < n; j++ {
					temp := a[j-1]
					a[j-1] = a[j]
					a[j] = temp
				}
				//printArr(a)
				step++
			}
			count++
			index++
		}
		if count == ones {
			break
		}
	}

	return step
}

func moveToRight(a []int, n int, ones int) int {

	var index int = n - 1
	step := 0

	for index >= 0 {
		if a[index] == 1 {
			index--
		} else {
			for a[index] != 1 {
				for j := index; j > 0; j-- {
					temp := a[j-1]
					a[j-1] = a[j]
					a[j] = temp
				}
				//printArr(a)
				step++
			}
			index--
		}
		if index == n-1-ones {
			break
		}
	}

	return step
}

func printArr(a []int) {
	for i := range a {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println()
}

package main

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

func main() {
	var t, n int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &t)
	for i := 0; i < t; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &n)
		scanner.Scan()
		books := strings.Split(scanner.Text(), " ")
		lbook := -1
		rbook := 0
		nbook := 0
		for i, v := range books {
			if lbook == -1 && v == "1" {
				lbook = i
				rbook = i
			} else if lbook != -1 && v == "1" {
				rbook = i
				nbook++
			}
		}
		space := rbook - lbook - nbook
		//spaceL := lbook
		//spaceR := len(books) - rbook - 1
		ans := space //+ min(spaceL, spaceR)
		//fmt.Println(lbook, rbook, nbook)
		fmt.Println(ans)
	}
}

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

package main

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

func getIndex(length int64, arr []string) []int64 {

	var i int64
	var ones []int64
	for i = 0; i < length; i++ {
		if arr[i] == "1" {
			ones = append(ones, i)
		}
	}

	return ones
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	testCases := scanner.Text()

	var tc int64
	tc, _ = strconv.ParseInt(testCases, 10, 64)

	for tc > 0 {

		scanner.Scan()
		size := scanner.Text()
		var length, oneLen int64
		var ones []int64

		length, _ = strconv.ParseInt(size, 10, 64)

		scanner.Scan()
		arr := scanner.Text()
		strArr := strings.Split(arr, " ")

		ones = getIndex(length, strArr)

		oneLen = int64(len(ones))

		fmt.Println(ones[oneLen-1] - ones[0] - 1 - (oneLen - 2))

		tc--

	}
}

package main

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

func maketest(books string) {
	ret := 0
	ba := strings.Split(books, " ")
	i:= 0
	f:= false
	for i<len(ba) {
	    if ba[i]=="1" {
	        f=true
	        break
	    }
	    i++
	}
	if f {
	    gap:=0
	    i++
	    for i<len(ba) {
    	    if ba[i-1]=="1" && ba[i]=="0" {
    	       gap++
    	    } else if ba[i-1]=="0" && ba[i]=="0" {
    	       gap++
    	    }else if ba[i-1]=="0" && ba[i]=="1" {
    	        ret+=gap
    	        gap=0
    	    }
    	    i++
    	}
	}
    fmt.Println(ret)
}

func main() {
	cin := bufio.NewReader(os.Stdin)
	nts, err := cin.ReadString('\r')
	if err != nil {
		fmt.Println("a", err)
		return
	}
	cin.ReadByte()
	numtests, err := strconv.ParseInt(nts[:len(nts)-1], 10, 64)
	if err != nil {
		fmt.Println("b", err)
		return
	}
	for i := 0; i < int(numtests); i++ {
		_, err := cin.ReadString('\r')
		if err != nil {
			fmt.Println("c", err)
			return
		}
		cin.ReadByte()
		books, err := cin.ReadString('\r')
		if err != nil {
			fmt.Println("c", err)
			return
		}
		cin.ReadByte()
		maketest(books[:len(books)-1])
	}
}

package main

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

var T, n int

var _r = bufio.NewReader(os.Stdin)
var _w = bufio.NewWriter(os.Stdout)

func main() {
	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		_, _ = fmt.Fscan(_r, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			_, _ = fmt.Fscan(_r, &a[i])
		}
		var b []int
		for i := 1; i <= n; i++ {
			if a[i] == 1 && a[i-1] == 1 {
				continue
			}
			b = append(b, a[i])
		}
		for len(b) > 0 && b[0] == 0 {
			b = b[1:] //pop_front
		}
		for len(b) > 0 && b[len(b)-1] == 0 {
			b = b[:len(b)-1] //pop_back
		}
		ans := 0
		for _, val := range b {
			if val == 0 {
				ans++
			}
		}

		//fmt.Println(b)
		_, _ = fmt.Fprintln(_w, ans)
		_ = _w.Flush()
	}

}

package main

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

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 solveA() {
	var s string
	scanf("%s\n", &s)
	dig := int(s[0] - '0')
	len := len(s)
	ans := (dig - 1) * 10 + len * (len + 1) / 2
	printf("%d\n", ans)
}

func solveB() {
	n := 0
	scanf("%d\n", &n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		if i + 1 == n {
			scanf("%d\n", &v[i])
		} else {
			scanf("%d ", &v[i])
		}
	}
	fir := -1
	lst := -1
	for i := 0; i < n; i++ {
		if v[i] == 0 {
			continue
		}
		if fir == -1 {
			fir = i
		}
		lst = i
	}
	ans := 0
	for i := fir; i <= lst; i++ {
		ans += 1 - v[i]
	}
	printf("%d\n", ans)
}

func solveC() {
	n := 0
	scanf("%d\n", &n)
	v := make([]int, n)
	indMx := 0
	for i := 0; i < n; i++ {
		if i + 1 == n {
			scanf("%d\n", &v[i])
		} else {
			scanf("%d ", &v[i])
		}
		if v[i] > v[indMx] {
			indMx = i
		}
	}
	ans := -1
	for i := indMx; i < n; i++ {
		if v[i] != v[indMx] {
			continue
		}
		if i - 1 >= 0 && v[i - 1] != v[indMx] {
			ans = i + 1
			break
		}
		if i + 1 < n && v[i + 1] != v[indMx] {
			ans = i + 1
			break
		}
	}
	printf("%d\n", ans)
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solveB()
	}
}

package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		n := ReadInt()
		a := ReadInts(n)
		println(solve(n, a))
	}
}

func solve(n int, a []int) int {
	zeros := 0
	for _, ai := range a {
		if ai == 0 {
			zeros++
		}
	}

	if zeros == n-1 {
		return 0
	}

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

	rzeros := 0
	for i := n - 1; i >= 0; i-- {
		if a[i] == 1 {
			break
		}
		rzeros++
	}

	return zeros - lzeros - rzeros
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

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

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

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

var scanner *bufio.Scanner

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

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

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		arr := make([]bool, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &arr[i])
		}

		ok := false
		var ans, a int
		for i := 0; i < n; i++ {

			if arr[i] == true {
				ok = true
				ans += a
				a = 0
				continue
			}

			if arr[i] == false && ok == true {
				a++
			}
		}

		fmt.Println(ans)
	}
}

package main

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

var t int

func getMin(q1, q2 int) int {
	if q1 > q2 {
		return q2
	} else {
		return q1
	}
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		arr := make([]bool, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &arr[i])
		}

		ok := false
		var sumOne, a int
		for i := 0; i < n; i++ {

			if arr[i] == true {
				ok = true
				sumOne += a
				a = 0
				continue
			}

			if arr[i] == false && ok == true {
				a++
			}
		}

		ok = false
		sumTwo := 0
		a = 0
		for i := n - 1; i >= 0; i-- {
			if arr[i] == true {
				ok = true
				sumTwo += a
				a = 0
				continue
			}

			if arr[i] == false && ok == true {
				a++
			}
		}

		fmt.Println(getMin(sumOne, sumTwo))
	}
}

package main
import (
	"bufio"
	"fmt"
	"os"
)
var rd = bufio.NewReader(os.Stdin)
func scanf(f string, a ...interface{}) {
	fmt.Fscanf(rd, f, a...)
}
func main() {
	q := 0
	scanf("%d\n", &q)
	for tc := 0; tc < q; tc++ {
		n := 0
		scanf("%d\n", &n)
		a := make([]int, n)
		for i := range a {
			if i == n - 1 {
				scanf("%d\n", &a[i])
			} else {
				scanf("%d ", &a[i])
			}
		}
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == 0 && i != 0 && j != n - 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
)

func main() {
	inp, _ := ioutil.ReadAll(os.Stdin)
	lines := strings.Split(strings.TrimSpace(string(inp)), "\n")
	var b strings.Builder
	for i := 2; i < len(lines); i += 2 {
		var a []int
		for _, s := range strings.Fields(lines[i]) {
			x, _ := strconv.Atoi(s)
			a = append(a, x)
		}
		for len(a) > 0 && a[0] == 0 {
			a = a[1:]
		}
		for len(a) > 0 && a[len(a)-1] == 0 {
			a = a[:len(a)-1]
		}
		ans := 0
		for _, x := range a {
			if x == 0 {
				ans++
			}
		}
		fmt.Fprintln(&b, ans)
	}
	fmt.Print(b.String())
}

package main

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

var (
	t    int16
	n    int8
	ones int8
)

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

	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)

		a := make([]int8, n)
		var b []int8

		ones = 0
		for i := range a {
			fmt.Fscan(reader, &a[i])
			b = append(b, a[i])
			if a[i] == 1 {
				ones++
			}
		}

		left := moveToLeft(a, n, ones)

		right := moveToRight(b, n, ones)

		if right >= left {
			fmt.Println(left)
		} else {
			fmt.Println(right)
		}
	}
}

func moveToLeft(a []int8, n int8, ones int8) int {

	var index int8 = 0
	step := 0

	for index < n {
		if a[index] == 1 {
			index++
		} else {
			for a[index] != 1 {
				for j := index + 1; j < n; j++ {
					temp := a[j-1]
					a[j-1] = a[j]
					a[j] = temp
				}
				//printArr(a)
				step++
			}
			index++
		}
		if index == ones {
			break
		}
	}

	return step
}

func moveToRight(a []int8, n int8, ones int8) int {

	var index int8 = n - 1
	step := 0

	for index >= 0 {
		if a[index] == 1 {
			index--
		} else {
			for a[index] != 1 {
				for j := index; j > 0; j-- {
					temp := a[j-1]
					a[j-1] = a[j]
					a[j] = temp
				}
				//printArr(a)
				step++
			}
			index--
		}
		if index == n-1-ones {
			break
		}
	}

	return step
}

func printArr(a []int8) {
	for i := range a {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println()
}

package main

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

func main() {
	var t, n int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &t)
	for i := 0; i < t; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &n)
		scanner.Scan()
		books := strings.Split(scanner.Text(), " ")
		lbook := -1
		rbook := 0
		nbook := 0
		for i, v := range books {
			if lbook == -1 && v == "1" {
				lbook = i
			} else if lbook != -1 && v == "1" {
				rbook = i
				nbook++
			}
		}
		space := rbook - lbook - nbook
		spaceL := lbook
		spaceR := len(books) - rbook - 1
		ans := space + min(spaceL, spaceR)
		//fmt.Println(lbook, rbook, nbook)
		fmt.Println(ans)
	}
}

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

package main

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

func main() {
	var t, n int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &t)
	for i := 0; i < t; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &n)
		scanner.Scan()
		books := strings.Split(scanner.Text(), " ")
		lbook := -1
		rbook := 0
		nbook := 0
		for i, v := range books {
			if lbook == -1 && v == "1" {
				lbook = i
				rbook = i
			} else if lbook != -1 && v == "1" {
				rbook = i
				nbook++
			}
		}
		space := rbook - lbook - nbook
		spaceL := lbook
		spaceR := len(books) - rbook - 1
		ans := space + min(spaceL, spaceR)
		//fmt.Println(lbook, rbook, nbook)
		fmt.Println(ans)
	}
}

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

package main
import (
	"bufio"
	"fmt"
	"os"
	"strings"
)
func scanInt() int {
	sc, res := bufio.NewScanner(os.Stdin), 0
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &res)
	return res
}
func scanArray() []string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	return strings.Split(sc.Text(), " ")
}
func main() {
	q := scanInt()
	for tc := 0; tc < q; tc++ {
		n, a := scanInt(), scanArray()
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == "0" && i != 0 && j != n - 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import
	"fmt"
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for tc := 0; tc < q; tc++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		a := make([]int, n)
		for i := range a {
			if i == n - 1 {
				fmt.Scanf("%d\n", &a[i])
			} else {
				fmt.Scanf("%d ", &a[i])
			}
		}
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == 0 && i != 0 && j != n - 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import (
	"bufio"
	"fmt"
	"os"
	"strings"
)
func scanInt() int {
	sc, res := bufio.NewScanner(os.Stdin), 0
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d", &res)
	return res
}
func scanArray() []string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	return strings.Split(sc.Text(), " ")
}
func main() {
	q := scanInt()
	for i := 0; i < q; i++ {
		n, a := scanInt(), scanArray()
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == "0" && i != 0 && j != n - 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		n, s := 0, ""
		fmt.Scanf("%n\n%s\n", &n, &s)
		a := strings.Split(s, " ")
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == "0" && i != 0 && j != n + 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import "fmt"
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		a := make([]int, n)
		for i := range a {
			fmt.Scanf("%d", &a[i])
		}
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == 0 && i > 0 && j != n + 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		n, s := 0, ""
		fmt.Scanf("%n\n%s\n", &s)
		a := strings.Split(s, " ")
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == "0" && i != 0 && j != n + 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		n, s := 0, ""
		fmt.Scanf("%s\n", &s)
		a := strings.Split(s, " ")
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == "0" && i != 0 && j != n + 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}

package main
import "fmt"
func main() {
	q := 0
	fmt.Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		a := make([]int, n)
		for i := range a {
			fmt.Scanf("%d ", &a[i])
		}
		i, res := 0, 0
		for i < n {
			j := i
			for j + 1 < n && a[j + 1] == a[i] {
				j++
			}
			if a[i] == 0 && i != 0 && j != n + 1 {
				res += j - i + 1
			}
			i = j + 1
		}
		fmt.Println(res)
	}
}


package main

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

/* solution */

func solve() {

	n := readInt()

	g := readInt64()
	for i := 1; i < n; i++ {
		g = gcd(g, readInt64())
	}

	ans := 0
	for i := int64(1); i <= int64(math.Sqrt(float64(g))+1e-3); i++ {
		if g%i == 0 {
			ans += 2
			if i*i == g {
				ans--
			}
		}
	}

	printInt(ans)

}

func gcd(a, b int64) int64 {
	if a > b {
		a, b = b, a
	}
	if a == 1 {
		return int64(1)
	}
	if a == 0 {
		return b
	}
	return gcd(a, b%a)
}

/* 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)
	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 readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

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

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

package main

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

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

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

	var N int64
	fmt.Fscanf(input, "%d\n", &N)
	A := make([]int64, N)
	for n := int64(0); n < N; n++ {
		fmt.Fscanf(input, "%d", &A[n])
	}

	x := A[0]
	for n := int64(1); n < N; n++ {
		x = gcd(A[n], x)
	}
	ds := make(map[int64]bool)
	for i := int64(1); i*i <= x; i++ {
		if x%i == 0 {
			ds[i] = true
			ds[x/i] = true
		}
	}
	fmt.Println(len(ds))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
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()
	var n,i int64
	var a,ans int64
	scanf("%d",&n)
	scanf("%d",&ans)
	for i=0;i<n;i++{
		scanf("%d",&a)
		if i==0{
			ans=a
		}else {
			ans = gcd(ans, a)
		}
	}
	cnt:=0
	for i=1;i*i<=ans;i++{
		if ans%i==0 &&i==ans/i{
			cnt++
		}else if ans%i==0{
				cnt+=2
		}
	}
	fmt.Println(cnt)
}

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

package main

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

func main() {
	defer Flush()

	n, a := readIntsll(0)
	_ = n
	d := a[0]
	for _, v := range a {
		d = gcdll(d, v)
	}

	f := make(map[int64]int64)
	for i := int64(2); i*i <= d; i++ {
		for d%i == 0 {
			f[i]++
			d /= i
		}
	}
	if d != 1 {
		f[d]++
	}

	ans := int64(1)
	for _, v := range f {
		ans *= v + 1
	}
	println(ans)

}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

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

func gcdSlice(a []int64) int64 {
	r := a[0]
	for i := 1; i < len(a); i++ {
		r = gcd(r, a[i])
	}
	return r
}

func divisors(n int64) []int64 {
	r := []int64{}
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n%int64(i) == 0 {
			r = append(r, int64(i))
			if n / int64(i) != int64(i) {
				r = append(r, n / int64(i))
			}
		}
	}
	return r
}

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]int64, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	p := gcdSlice(a)

	d := divisors(p)

	fmt.Println(len(d))
}

package main

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

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

func gcdSlice(a []int64) int64 {
	r := a[0]
	for i := 0; i < len(a); i++ {
		r = gcd(r, a[i])
	}
	return r
}

func divisors(n int64) []int64 {
	r := []int64{}
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n%int64(i) == 0 {
			r = append(r, int64(i))
			if n / int64(i) != int64(i) {
				r = append(r, n / int64(i))
			}
		}
	}
	return r
}

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]int64, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	p := gcdSlice(a)

	d := divisors(p)

	fmt.Println(len(d))
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i

}

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

	var n int
	var g int64

	n = nextInt()

	for i := 0; i < n; i++ {
		var a int64
		a = nextInt64()
		g = gcd(g, a)
	}

	var i, ans int64

	for i = 1; i*i <= g; i++ {
		if g%i == 0 {
			ans += 2
		}
		if i*i == g {
			ans--
		}
	}
	fmt.Println(ans)
}

package main
import "fmt"
import "os"
import "bufio"

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

func resolve(a int64) int {
	ans := 0
	for i:=int64(1); i*i<=a; i++ {
		if a%i==0 {
			ans++
			if a/i!=i {
				ans++
			}
		}
	}
	return ans
}

func main(){
	var n int
	input := bufio.NewReader(os.Stdin)
	fmt.Fscanf(input, "%d\n", &n)
	var ans int64 = 0
	for i:=1; i<=n; i++ {
		var x int64
		fmt.Fscanf(input, "%d", &x)
		ans = __gcd(ans, x)
	}
	fmt.Println(resolve(ans))
}

package main

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

var (
	n int
)

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	// file, err := os.Open("input.txt")
	// if err != nil {
	// 	panic(err)
	// }
	// reader := bufio.NewReader(file)

	fmt.Fscanf(reader, "%d\n", &n)

	nums := make([]int64, n)
	var g int64
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &nums[i])
		g = gcd(nums[i], g)
	}

	count := 0
	var i int64
	for i = 1; i*i <= g; i++ {
		if g%i == 0 {
			count++

			if i != g/i {
				count++
			}

		}
	}

	fmt.Println(count)
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt64() int64 {
	i, e := strconv.ParseInt(nextString(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func main() {
	sc.Buffer(make([]byte, 0), 1000000009)
	sc.Split(bufio.ScanWords)

	var n int
	var g int64

	n = nextInt()

	for i := 0; i < n; i++ {
		a := nextInt64()
		g = gcd(g, a)
	}
	var i, ans int64

	for i = 1; i*i <= g; i++ {
		if g%i == 0 {
			ans += 2
		}
		if i*i == g {
			ans--
		}
	}
	fmt.Println(ans)
}

package main

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

var reader = bufio.NewReader(os.Stdin)  //use fmt.Fscan
var writer = bufio.NewWriter(os.Stdout) //use fmt.Fprintln

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

func numDivisors(num int64) int {
	var res int
	var i int64
	for i = 2; i*i <= num; i++ {
		if num%i == 0 {
			if i == num/i {
				res += 1
			} else {
				res += 2
			}
		}
	}
	if num == 1 {
		res += 1
	} else {
		res += 2
	}
	return res
}

func solve() {
	var n int
	fmt.Fscan(reader, &n)
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
	}
	var gcd int64 = arr[0]
	for i := 1; i < n; i++ {
		gcd = getGCD(gcd, arr[i])
	}
	fmt.Fprintln(writer, numDivisors(gcd))
}

func main() {
	var t int = 1
	// fmt.Fscan(reader, &t)
	defer writer.Flush()
	for t > 0 {
		solve()
		t--
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var n int

	_, err := fmt.Fscanf(input, "%d\n", &n)
	if err != nil {
	}

	var a = make([]int64, n)
	for i := 0; i < n; i++ {
		_, err := fmt.Fscanf(input, "%d", &a[i])
		if err != nil {
		}
	}
	_, err = fmt.Fscanf(input, "\n")
	if err != nil {
	}
	fmt.Println(countDivisors(gcdSlice(n, a)))
}

func gcdSlice(n int, values []int64) int64 {
	result := values[0]
	for i := 1; i < n; i++ {
		result = gcd(result, values[i])
	}
	return result
}

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

func countDivisors(n int64) int64 {
	var result int64
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n % int64(i) == 0 {
			if n / int64(i) == int64(i) {
				result++
			} else {
				result += 2
			}
		}
	}
	return result
}

package main

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

var reader = bufio.NewReader(os.Stdin)  //use fmt.Fscan
var writer = bufio.NewWriter(os.Stdout) //use fmt.Fprintln

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

func numDivisors(num int64) int {
	var res int
	var i int64
	for i = 2; i*i <= num; i++ {
		if num%i == 0 {
			if i == num/i {
				res += 1
			} else {
				res += 2
			}
		}
	}
	if num == 1 {
		res += 1
	} else {
		res += 2
	}
	return res
}

func solve() {
	var n int
	fmt.Fscan(reader, &n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
	}
	var gcd int = arr[0]
	for i := 1; i < n; i++ {
		gcd = getGCD(gcd, arr[i])
	}
	fmt.Fprintln(writer, numDivisors(int64(gcd)))
}

func main() {
	var t int = 1
	// fmt.Fscan(reader, &t)
	defer writer.Flush()
	for t > 0 {
		solve()
		t--
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var n int

	_, err := fmt.Fscanf(input, "%d\n", &n)
	if err != nil {
	}

	var a = make([]int64, n)
	for i := 0; i < n; i++ {
		_, err := fmt.Fscanf(input, "%d", &a[i])
		if err != nil {
		}
	}
	_, err = fmt.Fscanf(input, "\n")
	if err != nil {
	}
	println(countDivisors(gcdSlice(n, a)))
}

func gcdSlice(n int, values []int64) int64 {
	result := values[0]
	for i := 1; i < n; i++ {
		result = gcd(result, values[i])
	}
	return result
}

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

func countDivisors(n int64) int64 {
	var result int64
	for i := 1; i <= int(math.Sqrt(float64(n))); i++ {
		if n % int64(i) == 0 {
			if n / int64(i) == int64(i) {
				result++
			} else {
				result += 2
			}
		}
	}
	return result
}

package main

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

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

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

	var N int
	fmt.Fscanf(input, "%d\n", &N)
	A := make([]int, N)
	for n := 0; n < N; n++ {
		fmt.Fscanf(input, "%d", &A[n])
	}
	sort.Ints(A)
	divisors := make(map[int]bool)
	for i := 1; i*i <= A[0]; i++ {
		if A[0]%i == 0 {
			divisors[i] = true
			divisors[A[0]/i] = true
		}
	}
	var ans int
loop:
	for d := range divisors {
		for n := 1; n < N; n++ {
			if A[n]%d != 0 {
				continue loop
			}
		}
		ans++
	}
	fmt.Println(ans)
}

package main

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

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

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

	var N int
	fmt.Fscanf(input, "%d\n", &N)
	A := make([]int, N)
	for n := int(0); n < N; n++ {
		fmt.Fscanf(input, "%d", &A[n])
	}

	x := A[0]
	for n := 1; n < N; n++ {
		x = gcd(A[n], x)
	}
	ds := make(map[int]bool)
	for i := int(1); i*i <= x; i++ {
		if x%i == 0 {
			ds[i] = true
			ds[x/i] = true
		}
	}
	fmt.Println(len(ds))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
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()
	var n,i int64
	scanf("%d",&n)
	var a,ans int64
	for i=0;i<n;i++{
		scanf("%d",&a)
		if i==0{
			ans=a
		}else {
			ans = gcd(ans, a)
		}
	}
	cnt:=0
	for i=1;i*i<=ans;i++{
		if ans%i==0 &&i==ans/i{
			cnt++
		}else if ans%i==0{
				cnt+=2
		}
	}
	fmt.Println(cnt)
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)
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()
	var n,i int64
	scanf("%d",&n)
	var a,ans int64
	for i=0;i<n;i++{
		scanf("%d",&a)
		if i==0{
			ans=a
		}else {
			ans = gcd(ans, a)
		}
	}
	cnt:=0
	for i=1;i*i<=ans;i++{
		if ans%i==0 &&i==ans/i{
			cnt++
		}else{
				cnt+=2
		}
	}
	fmt.Println(cnt)
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)
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()
	var n,i int
	scanf("%d",&n)
	var a,ans int
	for i=0;i<n;i++{
		scanf("%d",&a)
		if i==0{
			ans=a
		}else {
			ans = gcd(ans, a)
		}
	}
	cnt:=0
	for i=1;i*i<=ans;i++{
		if ans%i==0 &&i==ans/i{
			cnt++
		}else{
				cnt+=2
		}
	}
	fmt.Println(cnt)
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)
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()  {
	var n,i int
	scanf("%d",&n)
	var a,ans int
	for i=0;i<n;i++{
		scanf("%d",&a)
		if i==0{
			ans=a
		}else {
			ans = gcd(ans, a)
		}
	}
	cnt:=0
	for i=1;i*i<=ans;i++{
		if ans%i==0 &&i==ans/i{
			cnt++
		}else{
				cnt+=2
		}
	}
	fmt.Println(cnt)
}

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

package main

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

func main() {
	defer Flush()

	n, a := readIntsll(0)
	_ = n
	d := a[0]
	for _, v := range a {
		d = gcdll(d, v)
	}

	f := make(map[int64]int64)
	for i := int64(2); i*i <= d; i++ {
		if d%i == 0 {
			f[i]++
			d /= i
		}
	}
	if d != 1 {
		f[d]++
	}

	ans := int64(1)
	for _, v := range f {
		ans *= v + 1
	}
	println(ans)

}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

func divisors(n uint64) []uint64 {
	r := []uint64{}

	var i uint64 = 1
	for ; i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
		}
	}

	return r
}

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]uint64, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

	s := a[0]

	p := divisors(s)

	fmt.Println(p)

	k := 0
	for i := 0; i < len(p); i++ {
		ok := true
		for j := 0; j < len(a); j++ {
			if a[j]%p[i] != 0 {
				ok = false
				break
			}
		}
		if ok {
			k++
		}
	}

	fmt.Println(k)
}

package main

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

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	sort.Ints(a)

	s := a[0]

	k := 0
	for i := 1; i < s + 1; i++ {
		ok := true
		for j := 0; j < len(a); j++ {
			if a[j]%i != 0 {
				ok = false
				break
			}
		}
		if ok {
			k++
		}
	}

	fmt.Println(k)
}

package main

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

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	sort.Ints(a)

	fmt.Println(a)

	s := a[0]

	k := 0
	for i := 1; i < s + 1; i++ {
		ok := true
		for j := 0; j < len(a); j++ {
			if a[j]%i != 0 {
				ok = false
				break
			}
		}
		if ok {
			k++
		}
	}

	fmt.Println(k)
}

package main

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

func divisors(n uint64) []uint64 {
	r := []uint64{}

	var i uint64 = 1
	for ; i <= uint64(math.Sqrt(float64(n))); i++ {
		if n%i == 0 {
			r = append(r, i)
			if n/i != i {
				r = append(r, n/i)
			}
		}
	}

	return r
}

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

	n := 0
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]uint64, n)
	for j := 0; j < n; j++ {
		fmt.Fscanf(r, "%d", &a[j])
	}

	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

	s := a[0]

	p := divisors(s)

	fmt.Println(p)

	k := 0
	for i := 0; i < len(p); i++ {
		ok := true
		for j := 0; j < len(a); j++ {
			if a[j]%p[i] != 0 {
				ok = false
				break
			}
		}
		if ok {
			k++
		}
	}

	fmt.Println(k)
}

package main
import "fmt"
import "os"
import "bufio"

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

func resolve(a int) int {
	ans := 0
	for i:=1; i*i<=a; i++ {
		if a%i==0 {
			ans++
			if a/i!=i {
				ans++
			}
		}
	}
	return ans
}

func main(){
	var n int
	input := bufio.NewReader(os.Stdin)
	fmt.Fscanf(input, "%d\n", &n)
	var ans int = 0
	for i:=1; i<=n; i++ {
		var x int
		fmt.Fscanf(input, "%d", &x)
		ans = __gcd(ans, x)
	}
	fmt.Println(resolve(ans))
}

package main

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

var (
	n int
)

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	// file, err := os.Open("input.txt")
	// if err != nil {
	// 	panic(err)
	// }
	// reader := bufio.NewReader(file)

	fmt.Fscanf(reader, "%d\n", &n)

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

	count := 0
	for i := 1; i*i <= g; i++ {
		if g%i == 0 {
			count++

			if i != g/i {
				count++
			}

		}
	}

	fmt.Println(count)
}


package main

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

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

type stNode struct {
	l, r int
	val  int
}
type segmentTree []stNode

func (t segmentTree) _pushUp(o int) {
	lo, ro := t[o<<1], t[o<<1|1]
	t[o].val = max(lo.val, ro.val)
}

func (t segmentTree) _build(arr []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].val = arr[l-1]
		return
	}
	mid := (l + r) >> 1
	t._build(arr, o<<1, l, mid)
	t._build(arr, o<<1|1, mid+1, r)
	t._pushUp(o)
}

func (t segmentTree) _query(o, l, r int) (res int) {
	if l <= t[o].l && t[o].r <= r {
		return t[o].val
	}
	mid := (t[o].l + t[o].r) >> 1
	res = -1e9
	if l <= mid {
		res = max(res, t._query(o<<1, l, r))
	}
	if mid < r {
		res = max(res, t._query(o<<1|1, l, r))
	}
	return
}

func (t segmentTree) init(arr []int) { t._build(arr, 1, 1, len(arr)) }
func (t segmentTree) query(l, r int) int {
	if l > r {
		return 0
	}
	return t._query(1, l, r)
}

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

	var n int
	Fscan(in, &n)
	sumW := 0
	w := make([]int, n)
	h := make([]int, n)
	for i := range w {
		Fscan(in, &w[i], &h[i])
		sumW += w[i]
	}

	t := make(segmentTree, 4*n)
	t.init(h)
	for i, wi := range w {
		maxH := max(t.query(1, i), t.query(i+2, n))
		Fprint(out, (sumW-wi)*maxH, " ")
	}
}

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

// main
package main

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

var scanner *bufio.Scanner

func getI64() int64 {
    scanner.Scan()
    x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
    return x
}
func getI() int {
    return int(getI64())
}
func getF() float64 {
    scanner.Scan()
    x, _ := strconv.ParseFloat(scanner.Text(), 64)
    return x
}
func getS() string {
    scanner.Scan()
    return scanner.Text()
}

func main() {
    scanner = bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    defer writer.Flush()

    n := getI()
    sumW := 0
    w := make([]int, n)
    h := make([]int, n)
    maxH := make([]int, 2)
    for i := 0; i < n; i++ {
        w[i], h[i] = getI(), getI()
        sumW += w[i]
        if h[i] >= maxH[0] {
            maxH[1] = maxH[0]
            maxH[0] = h[i]
        } else if h[i] > maxH[1] {
            maxH[1] = h[i]
        }
    }
    for i := 0; i < n; i++ {
        curW := sumW - w[i]
        var curH int
        if h[i] == maxH[0] {
            curH = maxH[1]
        } else {
            curH = maxH[0]
        }
        writer.WriteString(fmt.Sprintf("%d\n", curH*curW))
    }
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strconv"
    "sort"
    // "strings"
    // "reflect"
)

type Reader struct{
    scanner *bufio.Scanner
}

func (read *Reader) init(){
    if read.scanner == nil {
        read.scanner = bufio.NewScanner(os.Stdin)
    }
}

func (read *Reader) setWord(){
    read.scanner.Split(bufio.ScanWords)
}

func (read *Reader) setByte(){
    read.scanner.Split(bufio.ScanBytes)
}

func (read *Reader) setLine(){
    read.scanner.Split(bufio.ScanLines)
}

func (read *Reader) read() string{
    read.scanner.Scan()
    return read.scanner.Text()
}

func (read *Reader) readInt() int{
    res,_ := strconv.Atoi(read.read())
    return res
}

func (read *Reader) readByte(length int) string{
    bt := make([]byte, length+2)
    for i := 0; i < length; i++ {
        bt[i] = read.read()[0]
    }

    return string(bt)
}

var read Reader
var sortByH bool

type Person struct{
    h, w, ind, ans int
}

type Persons []Person

func (a Persons) Len() int{
    return len(a)
}

func (a Persons) Swap(i, j int) {
    a[i], a[j] = a[j], a[i]
}

func (a Persons) Less(i, j int) bool{
    if(sortByH){
        return a[i].h < a[j].h
    } else{
        return a[i].ind < a[j].ind
    }
}

func main(){
    read.init()
    read.setWord()

    n := read.readInt()

    p := make([]Person, n)

    // read.setByte()
    // read.readByte(1)
    // read.setWord()

    totW := 0

    for i := 0; i < n; i++{
        p[i].w = read.readInt()
        p[i].h = read.readInt()
        p[i].ind = i
        totW += p[i].w
    }

    sortByH = true
    // fmt.Println(p)
    sort.Sort(Persons(p))

    for i := 0; i < n; i++{
        x,y := 0, 0
        x = totW - p[i].w
        if i == n-1{
            y = p[i-1].h
        } else {
            y = p[n-1].h
        }
        p[i].ans = x*y
    }

    sortByH = false
    sort.Sort(Persons(p))

    for i := 0; i < n; i++{
        if i > 0{
            fmt.Print(" ")
        }
        fmt.Print(p[i].ans)
    }

    // fmt.Println(p)

}

// main
package main

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

var (
    stdin  = bufio.NewReader(os.Stdin)
    stdout = bufio.NewWriter(os.Stdout)
)

func main() {
    defer stdout.Flush()
    var n int
    fmt.Fscanf(stdin, "%d", &n)
    sumW := 0
    w := make([]int, n)
    h := make([]int, n)
    maxH := make([]int, 2)
    for i := 0; i < n; i++ {
        fmt.Fscanf(stdin, "%d%d", &w[i], &h[i])
        sumW += w[i]
        if h[i] >= maxH[0] {
            maxH[1] = maxH[0]
            maxH[0] = h[i]
        } else if h[i] > maxH[1] {
            maxH[1] = h[i]
        }
    }
    for i := 0; i < n; i++ {
        curW := sumW - w[i]
        var curH int
        if h[i] == maxH[0] {
            curH = maxH[1]
        } else {
            curH = maxH[0]
        }
        fmt.Fprintf(stdout, "%d ", curH*curW)
    }
}

// main
package main

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

var (
    stdin  = bufio.NewReader(os.Stdin)
    stdout = bufio.NewWriter(os.Stdout)
)

func main() {
    defer stdout.Flush()
    var n int
    fmt.Fscanf(stdin, "%d", &n)
    sumW := 0
    w := make([]int, n)
    h := make([]int, n)
    maxH := make([]int, 2)
    for i := 0; i < n; i++ {
        fmt.Fscanf(stdin, "%d%d", &w[i], &h[i])
        sumW += w[i]
        if h[i] >= maxH[0] {
            maxH[1] = maxH[0]
            maxH[0] = h[i]
        } else if h[i] > maxH[1] {
            maxH[1] = h[i]
        }
    }
    for i := 0; i < n; i++ {
        curW := sumW - w[i]
        var curH int
        if h[i] == maxH[0] {
            curH = maxH[1]
        } else {
            curH = maxH[0]
        }
        fmt.Fprintln(stdout, curH*curW)
    }
}