package main

import (
	"fmt"
)

type point struct {
	x, y int
}

type union struct {
	next  *union
	depth int
	id    int
}

func (u *union) join(other *union) *union {
	for u.next != nil {
		u = u.next
	}
	for other.next != nil {
		other = other.next
	}
	if u == other {
		return u
	}
	if other.depth < u.depth {
		other.next = u
		return u
	} else if other.depth > u.depth {
		u.next = other
		return other
	}
	other.depth++
	u.next = other
	return other
}

func (u *union) last() *union {
	for u.next != nil {
		u = u.next
	}
	return u
}

func main() {
	var n int
	fmt.Scan(&n)
	sets := make(map[point]*union)
	verts := make(map[int][]point)
	horiz := make(map[int][]point)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		pt := point{x: x, y: y}
		sets[pt] = &union{id: i}
		verts[y] = append(verts[y], pt)
		horiz[x] = append(horiz[x], pt)

	}

	for _, list := range verts {
		x := list[0]
		for _, pt := range list {
			sets[x] = sets[x].join(sets[pt])
		}
	}
	for _, list := range horiz {
		x := list[0]
		for _, pt := range list {
			sets[x] = sets[x].join(sets[pt])
		}
	}
	result := make(map[*union]struct{})

	for _, u := range sets {
		result[u.last()] = struct{}{}
	}
	fmt.Println(len(result) - 1)
}

package main

import "os"
import "bufio"
import "strconv"

var a [110]int

func find(z int) int {
	if z == a[z] {
		return z
	} else {
		return find(a[z])
	}
}

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	x := make([]int, n)
	y := make([]int, n)
	count := 0
	for i:=0; i<n; i++ {
		a[i] = i
		r.Scan()
		x[i], _ = strconv.Atoi(r.Text())
		r.Scan()
		y[i], _ = strconv.Atoi(r.Text())
	}
	for j:=0; j<n; j++ {
		for k:=j+1; k<n; k++ {
			if x[j] == x[k] || y[j] == y[k] {
				a[find(j)] = find(k)
			}
		}
	}
	for l:=0; l<n; l++ {
		if a[l] == l {
			count += 1
		}
	}
	w.WriteString(strconv.Itoa(count-1)+"\n")
	w.Flush()
}

package main

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

// Took from here: https://www.codementor.io/tucnak/using-golang-for-competitive-programming-h8lhvxzt3
var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 10000000)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout,10000000)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

var n, count int
var matrix [1001][1001]int

func main() {
  // STDOUT MUST BE FLUSHED MANUALLY!!!
  defer writer.Flush()

  scanf("%d %d\n", &n)
  for i := 1; i <= n; i++ {
    var a, b int
    scanf("%d %d\n", &a, &b)
    matrix[a][b] = 1
  }

  for i := 1; i <= 1000; i++ {
    for j := 1; j <= 1000; j++ {
      if matrix[i][j] == 1 {
        count++
        dfs_adaptada(i, j)
        break
      }
    }
  }
  printf(strconv.Itoa(count - 1))
}

func dfs_adaptada(x, y int) () {
  if matrix[x][y] == 1 {
    matrix[x][y] = 2
    for i := 1; i <= 1000; i++ {
      if matrix[i][y] == 1 {
        dfs_adaptada(i, y)
      }
    }
    for j := 1; j <= 1000; j++ {
      if matrix[x][j] == 1 {
        dfs_adaptada(x, j)
      }
    }
  }
}

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	drifts := make([][2]int, n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		scanner.Scan()
		x, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		scanner.Scan()
		y, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		drifts[i] = [2]int{x - 1, y - 1}
	}

	sets := make(map[int]map[[2]int]bool)
	sets[1] = make(map[[2]int]bool)
	sets[1][drifts[0]] = true
	drifts[0][0] = -1
	drifts[0][1] = -1

	for i := 1; i <= n; i++ {
		for true { // Add new drifts into sets[i]
			before := len(sets[i])
			for j := 0; j < n; j++ {
				if drifts[j][0] >= 0 {
					x := drifts[j][0]
					y := drifts[j][1]
					ok := false
					for p, _ := range sets[i] {
						if p[0] == x || p[1] == y {
							ok = true
							break
						}
					}
					if ok {
						sets[i][[2]int{x, y}] = true
						drifts[j][0] = -1
						drifts[j][1] = -1
					}
				}
			}
			if len(sets[i]) == before {
				break
			}
		}

		more := false
		for j := 0; j < n; j++ {
			if drifts[j][0] >= 0 {
				sets[i+1] = make(map[[2]int]bool)
				sets[i+1][drifts[j]] = true
				more = true
				break
			}
		}
		if !more {
			break
		}
	}

	fmt.Println(len(sets) - 1)
}

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	drifts := make([][2]int, n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		scanner.Scan()
		x, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		scanner.Scan()
		y, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		drifts[i] = [2]int{x - 1, y - 1}
	}

	sets := make(map[int]map[[2]int]bool)
	sets[1] = make(map[[2]int]bool)
	sets[1][drifts[0]] = true
	drifts[0][0] = -1
	drifts[0][1] = -1

	for i := 1; i <= n; i++ {
		for true { // Add new drifts into sets[i]
			before := len(sets[i])
			for j := 0; j < n; j++ {
				if drifts[j][0] >= 0 {
					x := drifts[j][0]
					y := drifts[j][1]
					ok := false
					for p, _ := range sets[i] {
						if p[0] == x || p[1] == y {
							ok = true
							break
						}
					}
					if ok {
						sets[i][[2]int{x, y}] = true
						drifts[j][0] = -1
						drifts[j][1] = -1
					}
				}
			}
			if len(sets[i]) == before {
				break
			}
		}

		for j := 0; j < n; j++ {
			if drifts[j][0] >= 0 {
				sets[i+1] = make(map[[2]int]bool)
				sets[i+1][drifts[j]] = true
				break
			}
		}
	}

	fmt.Println(len(sets) - 1)
}

package main

import "fmt"

type UnionFindDisjointSet struct {
    pset []int
    cnt int
}

func (u *UnionFindDisjointSet) InitSet(n int) {
    u.pset = make([]int,n)
    for i := 0; i < n; i++ { u.pset[i] = i }
    u.cnt = n
}

func (u *UnionFindDisjointSet) FindSet(i int) int {
    if u.pset[i] != i { u.pset[i] = u.FindSet(u.pset[i]) }
    return u.pset[i]
}

func (u *UnionFindDisjointSet) IsSameSet(i,j int) bool {
    return u.FindSet(i) == u.FindSet(j)
}

func (u *UnionFindDisjointSet) UnionSet(i,j int) {
    u.pset[u.FindSet(i)] = u.FindSet(j)
    u.cnt--
}

func main() {
    var n int
    var x,y [105]int
    var u UnionFindDisjointSet
    fmt.Scan(&n)
    u.InitSet(n)
    for i := 0; i < n; i++ { fmt.Scan(&x[i],&y[i]) }
    for i := 0; i < n; i++ {
        for j := i+1; j < n; j++ {
            if ((x[i] == x[j]) || (y[i] == y[j])) && !u.IsSameSet(i,j) {
                u.UnionSet(i,j)
            }
        }
    }
    fmt.Println(u.cnt-1)
}

//https://codeforces.com/problemset/problem/217/A
//http://bigocoder.com/courses/BLUE20/BLUE20_LEC16/BLUE_L16P05/statement
package main

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

var (
	rank   []int
	parent []int
)

type snowDrift struct {
	x int
	y int
}

func makeSet(n int) {
	parent = make([]int, n)

	for i := range parent {
		parent[i] = i
	}
}

func unionSet(a int, b int) {
	aParent := findSet(a)
	bParent := findSet(b)

	if aParent == bParent {
		return
	}
	if rank[aParent] > rank[bParent] {
		parent[bParent] = aParent
		return
	}
	if rank[aParent] < rank[bParent] {
		parent[aParent] = bParent
		return
	}

	parent[bParent] = aParent
	rank[aParent]++
}

func findSet(v int) int {
	if v != parent[v] {
		parent[v] = findSet(parent[v])
	}

	return parent[v]
}

func isSameSet(a snowDrift, b snowDrift) bool {
	return a.x == b.x || a.y == b.y
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, set int
	fmt.Fscanf(r, "%d\n", &n)
	rank = make([]int, n)
	drifts := make([]snowDrift, n)
	makeSet(n)

	for i := range drifts {
		fmt.Fscanf(r, "%d %d\n", &drifts[i].x, &drifts[i].y)
		for j := 0; j < i; j++ {
			if isSameSet(drifts[i], drifts[j]) {
				unionSet(i, j)
			}
		}
	}

	for i := range parent {
		if i == parent[i] {
			set++
		}
	}

	fmt.Fprintf(os.Stdout, "%d\n", set-1)
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

type Point struct {
	x, y int
	visited bool
}

func flood(points []Point, pos int) {
	points[pos].visited = true
	x, y := points[pos].x, points[pos].y
	for i := 0; i < len(points); i++ {
		if !points[i].visited && (points[i].x == x || points[i].y == y) {
			flood(points, i)
		}
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	points := make([]Point, n)
	for i := 0; i < n; i++ {
		points[i] = Point{x: scanInt(scanner), y: scanInt(scanner)}
	}
	count := -1
	for i := 0; i < n; i++ {
		if points[i].visited {
			continue
		}
		count++
		flood(points, i)
	}
	writer.WriteString(fmt.Sprintf("%d\n", count))
}

package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scan(&n)

	x, y := make([]int, n), make([]int, n)
	parent := make([]int, n)
	sz := make([]int, n)

	for i := 0; i < n; i++ {
		parent[i] = i
		sz[i] = 1
		fmt.Scan(&x[i], &y[i])
	}

	var find func(int) int
	find = func(a int) int {
		if parent[a] == a {
			return a
		}
		parent[a] = find(parent[a])
		return parent[a]
	}

	var unite func(int, int)
	unite = func(a, b int) {
		a = find(a)
		b = find(b)
		if a != b {
			if sz[b] > sz[a] {
				a = a ^ b
				b = a ^ b
				a = a ^ b
			}
			parent[b] = a
			sz[a] += sz[b]
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if x[i] == x[j] || y[i] == y[j] {
				unite(i, j)
			}
		}
	}

	ans := -1
	for i := 0; i < n; i++ {
		if i == find(i) {
			ans++
		}
	}
	fmt.Print(ans)
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n := io.NextInt()

	x, y := make([]int, n), make([]int, n)
	parent := make([]int, n)
	sz := make([]int, n)

	for i := 0; i < n; i++ {
		parent[i] = i
		sz[i] = 1
		x[i], y[i] = io.NextInt(), io.NextInt()
	}

	var find func(int) int
	find = func(a int) int {
		if parent[a] == a {
			return a
		}
		parent[a] = find(parent[a])
		return parent[a]
	}

	var unite func(int, int)
	unite = func(a, b int) {
		a = find(a)
		b = find(b)
		if a != b {
			if sz[b] > sz[a] {
				a = a ^ b
				b = a ^ b
				a = a ^ b
			}
			parent[b] = a
			sz[a] += sz[b]
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if x[i] == x[j] || y[i] == y[j] {
				unite(i, j)
			}
		}
	}

	ans := -1
	for i := 0; i < n; i++ {
		if i == find(i) {
			ans++
		}
	}

	io.Println(ans)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

// 217A
package main

import (
	"fmt"
)

var (
	d, a, s       [100]int
	q, w, e, r, t int
)

func l(q int) int {
	if d[q] != q {
		d[q] = l(d[q])
	}
	return d[q]
}
func main() {
	fmt.Scan(&q)
	t = q - 1
	for w = 0; w < q; w++ {
		fmt.Scan(&a[w], &s[w])
		d[w] = w
		for e = 0; e < w; e++ {
			if (a[e] == a[w]) || (s[e] == s[w]) {
				r = l(e)
				if r != w {
					d[r] = w
					t--
				}
			}
		}
	}
	fmt.Print(t)
}

package main

import "fmt"

// Edge is a intermediate representation of edge on DirectedGraph
type Edge struct {
	From  Vertex
	To    Vertex
	Value Rel // raw value of edge
}
type Vertex struct {
	Value interface{}
}
type Rel string
type DirectedGraph struct {
	Outs map[Vertex]map[Vertex][]Rel
	Ins  map[Vertex][]Vertex
}

// Vertices returns the set of all vertices in graph
func (g *DirectedGraph) Vertices() []Vertex {
	vertices := []Vertex{}

	for key := range g.Outs {
		vertices = append(vertices, key)
	}
	return vertices
/*	vertices := []Vertex{}
	haveIn := make(map[Vertex]bool)

	for key := range g.Outs {
		vertices = append(vertices, key)
		haveIn[key] = true
		for vertex, _ := range g.Outs[key] {
			_, ok := haveIn[vertex]
			if ok == false {
				vertices = append(vertices, vertex)
				fmt.Println(vertex, "   !")
			}
		}
	}
	return vertices*/
}

// In returns inbound vertices to v in graph g
func (g *DirectedGraph) In(v Vertex) []Vertex {
	_, ok := g.Ins[v]
	if !ok {
		return []Vertex{}
	} else {
		return g.Ins[v]
	}
}

// Out returns outbound vertices from v in graph g
func (g *DirectedGraph) Out(v Vertex) []Vertex {
	_, ok := g.Outs[v]
	if !ok {
		return []Vertex{}
	}

	vertices := []Vertex{}

	for key := range g.Outs[v] {
		vertices = append(vertices, key)
	}
	return vertices
}

// Edges returns the edge between two vertices
func (g *DirectedGraph) Edges(a, b Vertex) []Edge {
	_, oka := g.Outs[a]
	_, okb := g.Ins[b]
	if !oka || !okb {
		return nil
	}

	_, ok := g.Outs[a][b]
	if !ok {
		return nil
	}

	edges := []Edge{}
	for _, rel := range g.Outs[a][b] {
		edges = append(edges, Edge{
			From:  a,
			To:    b,
			Value: rel,
		})
	}
	return edges
}

// Link links two vertices relationship
func (g *DirectedGraph) Link(v Vertex, succ Vertex, rel Rel) {
	_, ok := g.Outs[v]
	if !ok {
		g.Outs[v] = make(map[Vertex][]Rel)
	}
	_, ok = g.Outs[succ]
	if !ok {
		g.Outs[succ] = make(map[Vertex][]Rel)
	}

	_, ok = g.Ins[v]
	if !ok {
		g.Ins[v] = []Vertex{}
	}
	_, ok = g.Ins[succ]
	if !ok {
		g.Ins[succ] = []Vertex{}
	}

	haveRel := false
	for _, item := range g.Outs[v][succ] {
		if item == rel {
			haveRel = true
			break
		}
	}
	if haveRel == false {
		g.Outs[v][succ] = append(g.Outs[v][succ], rel)
	}

	haveV := false
	for _, item := range g.Ins[succ] {
		if item == v {
			haveV = true
			break
		}
	}
	if haveV == false {
		g.Ins[succ] = append(g.Ins[succ], v)
	}
}

// LinkToAll links x to all ys
func (g *DirectedGraph) LinkToAll(x Vertex, ys []Vertex, rel Rel) {
	for _, y := range ys {
		g.Link(x, y, rel)
	}
}

// LinkAllTo links all xs to y
func (g *DirectedGraph) LinkAllTo(xs []Vertex, y Vertex, rel Rel) {
	for _, x := range xs {
		g.Link(x, y, rel)
	}
}

func (g *DirectedGraph) UnLink(a, b Vertex) {
	delete(g.Outs[a], b)
	/*if len(g.Outs[a]) == 0 {
		delete(g.Outs, a)
	}*/

	for id , vertex := range g.Ins[b] {
		if vertex == a {
			g.Ins[b] = append(g.Ins[b][:id], g.Ins[b][id+1:]...)
			break
		}
	}
	/*if len(g.Ins[b]) == 0 {
		delete(g.Ins, b)
	}*/
}

// Fork implements `forked` semantics on DirectedGraph
func (g *DirectedGraph) Fork() *DirectedGraph {
	return g
	//return deepcopy.Copy(g).(*DirectedGraph)
	//panic("impl me")
}
// IntersectionRel returns the union of res1 and res2
func IntersectionRel(rels1 []Rel,rels2 []Rel) []Rel{
	rel := []Rel{}
	for _, rel1 := range rels1 {
		both := false
		for _, rel2 := range rels2{
			if rel1 == rel2 {
				both = true
				break
			}
		}
		if both == true {
			rel = append(rel, rel1)
		}
	}
	return rel
}

// ProjectRelationship filters a graph to just those edges with the given relationship
func (g *DirectedGraph) ProjectRelationship(rel Rel) *DirectedGraph {
	fg := g.Fork()

	vertices := fg.Vertices()
	for _, x := range vertices {
		_, ok := g.Outs[x]
		if ok == true {
			for y, _:= range g.Outs[x] {
				rels := IntersectionRel(g.Outs[x][y], []Rel{rel})
				fg.UnLink(x, y)
				for _, item := range rels {
					fg.Link(x, y, item)
				}
			}
		}
	}

	return fg
}

// FilterRelationships filters a graph g to just those edges which intersect with the given set of
//  relationships
func (g *DirectedGraph) FilterRelationships(rels []Rel) *DirectedGraph {
	fg := g.Fork()

	vertices := fg.Vertices()
	for _, x := range vertices {
		_, ok := g.Outs[x]
		if ok == true {
			for y, _:= range g.Outs[x] {
				rels := IntersectionRel(g.Outs[x][y], rels)
				fg.UnLink(x, y)
				for _, item := range rels {
					fg.Link(x, y, item)
				}
			}
		}
	}

	return fg
}

// BfsOut searches from a vertices set, returns all vertices searchable
// search to downstream vertices from `out` edges
func (g *DirectedGraph) BfsOut(initV []Vertex) []Vertex {
	queue := initV
	V := []Vertex{}
	haveVisited := make(map[Vertex]bool)
	for _, vertex := range initV {
		haveVisited[vertex] = true
		V = append(V, vertex)
	}

	for len(queue) > 0 {
		cur := queue[0]
		if haveVisited[cur] == false {
			haveVisited[cur] = true
			V = append(V, cur)
		}
		queue = queue[1:]

		for next, _ := range g.Outs[cur] {
			if haveVisited[next] == true {
				continue
			}
			queue = append(queue, next)
		}
	}
	return V
}

// BfsIn searches from a vertices set, returns all vertices searchable
// search to upstream vertices from `in` edges
func (g *DirectedGraph) BfsIn(initV []Vertex) []Vertex {
	queue := initV
	V := []Vertex{}
	haveVisited := make(map[Vertex]bool)
	for _, vertex := range initV {
		haveVisited[vertex] = true
		V = append(V, vertex)
	}

	for len(queue) > 0 {
		cur := queue[0]
		if haveVisited[cur] == false {
			haveVisited[cur] = true
			V = append(V, cur)
		}
		queue = queue[1:]

		for _, next := range g.Ins[cur] {
			if haveVisited[next] == true {
				continue
			}
			queue = append(queue, next)
		}
	}
	return V
}

// Bfs searches from a vertices set, returns all vertices searchable
// out = true means search to downstream vertices from `out` edges
// out = false means search to upstream vertices from `in` edges
func (g *DirectedGraph) Bfs(initV []Vertex, out bool) []Vertex {
	if out == true {
		return g.BfsOut(initV)
	} else {
		return g.BfsIn(initV)
	}
}

// SCC indexes all vertices of a strongly connected component
type SCC struct {
	Vertices []Vertex
}

// StronglyConnectedComponents finds all strongly connected components
func (g *DirectedGraph) StronglyConnectedComponents() []SCC {
	dfn := make(map[Vertex]int)
	low := make(map[Vertex]int)
	cnt := 0
	belong := make(map[Vertex]int)
	in := make(map[Vertex]bool)
	tag := make(map[Vertex]map[Vertex]bool)
	s2 := []Vertex{}
	scc := []SCC{}
	vertices := g.Vertices()
	//index := 0
	for _, v := range vertices {
		if dfn[v] == 0 {
			s1 := []Vertex{v}
			index := 0
			for len(s1) > 0 {
				x := s1[len(s1)-1]
				s1 = s1[:len(s1)-1]
				if dfn[x] == 0 {
					index = index + 1
					dfn[x] = index
					low[x] = index
					s2 = append(s2, x)
					in[x] = true;
				}
				finish := true
				for next, _ := range g.Outs[x] {
					//fmt.Println("************")
					if dfn[next] == 0 {
						s1 = append(s1, x)
						s1 = append(s1, next)
						_, ok := tag[x]
						if !ok {
							tag[x] = make(map[Vertex]bool)
						}
						tag[x][next] = true
						finish = false
						break
					} else {
						if in[next] == true {
							if low[x] > dfn[next] {
								low[x] = dfn[next]
							}
						}
					}
				}
				if finish == true {
					//fmt.Println("??????????")
					for next, _ := range g.Outs[x] {
						_, ok := tag[x]
						if !ok {
							tag[x] = make(map[Vertex]bool)
						}
						if tag[x][next] == true {
							if low[x] > low[next] {
								low[x] = low[next]
							}
						}
					}
					//fmt.Println("!!!!!!!!!!!!")
					if low[x] == dfn[x] {
						var t Vertex
						cnt = cnt + 1
						for {
							t = s2[len(s2)-1]
							s2 = s2[:len(s2)-1]
							in[t] = false
							belong[t] = cnt;
							if t == x {
								break
							}
						}
					}
				}
			}
		}
	}
	//fmt.Println(cnt, "!!!!!")
	for i := 1; i <= cnt; i++ {
		ts := SCC{
			Vertices: []Vertex{},
		}
		for _, v := range vertices {
			if belong[v] == i {
				ts.Vertices = append(ts.Vertices, v)
			}
		}
		scc = append(scc, ts)
	}
	return scc
}

// MapVertices takes a function of vertices, returns graph with all
//  vertices mapped via f
func (g *DirectedGraph) MapVertices(f func(interface{}) interface{}) *DirectedGraph {
	//fmt.Println(f("consistent-view"))
	fg := NewDirectedGraph()

	vertices := g.Vertices()
	for _, x := range vertices {
		_, ok := g.Outs[x]
		if ok == true {
			for y, _:= range g.Outs[x] {
				rels := g.Outs[x][y]
				for _, item := range rels {
					fg.Link(Vertex{f(x.Value)}, Vertex{f(y.Value)}, item)
				}
			}
		}
	}

	return fg
}

var canonicalModelNames = map[string]string{
	"consistent-view":         "PL-2+",
	"conflict-serializable":   "PL-3",
	"cursor-stability":        "PL-CS",
	"forward-consistent-view": "PL-FCV",
	"monotonic-snapshot-read": "PL-MSR",
	"monotonic-view":          "PL-2L",
	"read-committed":          "PL-2",
	"read-uncommitted":        "PL-1",
	"repeatable-read":         "PL-2.99",
	"serializable":            "PL-3",
	"snapshot-isolation":      "PL-SI",
	"strict-serializable":     "PL-SS",
	"update-serializable":     "PL-3U",
	"0": "A",
	"1": "B",
	"2": "C",
}

// canonicalModelName can be applied to DirectedGraph.MapVertices
func canonicalModelName(name interface{}) interface{} {
	if cname, ok := canonicalModelNames[name.(string)]; ok {
		return cname
	}
	return name
}

// NewDirectedGraph returns a empty DirectedGraph
func NewDirectedGraph() *DirectedGraph {
	var g DirectedGraph
	g.Ins = make(map[Vertex][]Vertex)
	g.Outs = make(map[Vertex]map[Vertex][]Rel)
	return &g
}

// RenumberGraph takes a Graph and rewrites each vertex to a unique integer, returning the
//  rewritten Graph, and a vector of the original vertices for reconstruction.
// That means if we apply MapVertices to dg with remap, it can recover to g again
func (g *DirectedGraph) RenumberGraph() (*DirectedGraph, func(interface{}) interface{}) {
	dg := NewDirectedGraph()
	ref := make(map[Vertex]int)
	numberToVertices := make(map[interface{}]interface{})
	vertices := g.Vertices()

	for id, v := range vertices {
		ref[v] = id
		numberToVertices[id] = v.Value
	}

	for _, x := range vertices {
		for y, rels := range g.Outs[x] {
			for _, rel := range rels{
				dg.Link(Vertex{ref[x]}, Vertex{ref[y]}, rel)
			}
		}
	}

	return dg, func(number interface{}) interface{} {
		return numberToVertices[number]
	}
}

func (g *DirectedGraph) scctest() [][]int {
	dfn := make(map[Vertex]int)
	low := make(map[Vertex]int)
	cnt := 0
	belong := make(map[Vertex]int)
	in := make(map[Vertex]bool)
	tag := make(map[Vertex]map[Vertex]bool)
	s2 := []Vertex{}
	vertices := g.Vertices()
	ans := [][]int{}
	father := make(map[Vertex]Vertex)
	vv := Vertex{-1}
	index := 0
	for _, v := range vertices {
		if dfn[v] == 0 {
			s1 := []Vertex{v}
			father[v] = vv
			for len(s1) > 0 {
				x := s1[len(s1)-1]
				s1 = s1[:len(s1)-1]
				if dfn[x] == 0 {
					index = index + 1
					dfn[x] = index
					low[x] = index
					s2 = append(s2, x)
					in[x] = true;
				}
				finish := true
				for next, _ := range g.Outs[x] {
					if dfn[next] == 0 {
						s1 = append(s1, x)
						s1 = append(s1, next)
						father[next]=x
						_, ok := tag[x]
						if !ok {
							tag[x] = make(map[Vertex]bool)
						}
						tag[x][next] = true
						finish = false
						break
					} else {
						if in[next] == true {
							if low[x] > dfn[next] {
								low[x] = dfn[next]
								//fmt.Println("!!!!!!!")
								//ans = append(ans, []int{ x.Value.(int),next.Value.(int)})
							}
						}
					}
				}
				if finish == true {
					for next, _ := range g.Outs[x] {
						_, ok := tag[x]
						if !ok {
							tag[x] = make(map[Vertex]bool)
						}
						if tag[x][next] == true {
							if low[x] > low[next] {
								low[x] = low[next]
								//fmt.Println("!!!!!!")
								//ans = append(ans, []int{ x.Value.(int),next.Value.(int)})
							}
						}
					}
					if low[x] == dfn[x] {
						var t Vertex
						cnt = cnt + 1
						for {
							t = s2[len(s2)-1]
							s2 = s2[:len(s2)-1]
							in[t] = false
							belong[t] = cnt;
							if t == x {
								break
							}
						}
					}
				}
			}
		}
	}
	for i := 1; i <= cnt; i++ {
		ts := SCC{
			Vertices: []Vertex{},
		}
		for _, v := range vertices {
			if belong[v] == i {
				ts.Vertices = append(ts.Vertices, v)
			}
		}
		//fmt.Println(ts)
	}

	/*for _, x := range vertices{
		for y, _ := range g.Outs[x] {
			if low[x] != low[y] {
				ans = append(ans, []int{ x.Value.(int),y.Value.(int)})
			}
		}
	}*/
	for _, i:= range vertices{
		v:= father[i]
		//fmt.Println(i , "  " ,v )
		if v != vv {
			fmt.Println(low[i]," ",dfn[v])
			//ans = append(ans, []int{ i.Value.(int),v.Value.(int)})
		}
	}

	return ans
}

func criticalConnections(n int, connections [][]int) [][]int {
	g := NewDirectedGraph()
	for _, b := range connections{
		g.Link(Vertex{b[0]},Vertex{b[1]},"")
		g.Link(Vertex{b[1]},Vertex{b[0]},"")
	}

	return g.scctest()
}

func main () {
	/*var g DirectedGraph
	g.Ins = make(map[Vertex][]Vertex)
	g.Outs = make(map[Vertex]map[Vertex][]Rel)
	g.Link(Vertex{0},Vertex{1},"")
	g.Link(Vertex{1},Vertex{2},"")
	g.Link(Vertex{2},Vertex{3},"")
	g.Link(Vertex{3},Vertex{2},"")
	g.Link(Vertex{3},Vertex{7},"")
	g.Link(Vertex{7},Vertex{3},"")
	g.Link(Vertex{2},Vertex{6},"")
	g.Link(Vertex{7},Vertex{6},"")
	g.Link(Vertex{5},Vertex{6},"")
	g.Link(Vertex{6},Vertex{5},"")
	g.Link(Vertex{1},Vertex{5},"")
	g.Link(Vertex{4},Vertex{5},"")
	g.Link(Vertex{4},Vertex{0},"")
	g.Link(Vertex{1},Vertex{4},"")
	// init done ==================================
	// scc ========================================
	scc := g.StronglyConnectedComponents()
	fmt.Println(len(scc))
	fmt.Println(scc)*/
	//(5, 6) (7, 3, 2) (4, 1, 0)
	// scc done ===================================

	/*var g DirectedGraph
	g.Ins = make(map[Vertex][]Vertex)
	g.Outs = make(map[Vertex]map[Vertex][]Rel)
	g.Link(Vertex{"0"},Vertex{"1"},"aa")
	g.Link(Vertex{"0"},Vertex{"1"},"bb")
	//g.Link(Vertex{"0"},Vertex{"2"},"")
	g.Link(Vertex{"1"},Vertex{"2"},"cc")
	g.Link(Vertex{"2"},Vertex{"3"},"")

//	g.UnLink(Vertex{"0"},Vertex{"1"})
	fmt.Println(g.Ins)
	fmt.Println(g.Outs)
	fmt.Println(g.Vertices())
	xxx := g.MapVertices(canonicalModelName)
	fmt.Println(xxx.Ins)
	fmt.Println(xxx.Outs)
	//fmt.Println("!!!!!!!")
	fmt.Println(xxx.Vertices())*/

	/*var g DirectedGraph
	g.Ins = make(map[Vertex][]Vertex)
	g.Outs = make(map[Vertex]map[Vertex][]Rel)
	g.Link(Vertex{"A"},Vertex{"B"},"aa")
	g.Link(Vertex{"A"},Vertex{"B"},"bb")
	//g.Link(Vertex{"0"},Vertex{"2"},"")
	g.Link(Vertex{"B"},Vertex{"C"},"cc")
	g.Link(Vertex{"C"},Vertex{"D"},"")
	dg, remap := g.RenumberGraph()
	fmt.Println(g.Ins)
	fmt.Println(g.Outs)
	//fmt.Println(dg.Ins)
	//fmt.Println(dg.Outs)

	xx := dg.MapVertices(remap)
	fmt.Println(xx.Ins)
	fmt.Println(xx.Outs)*/

	/*var connections [][]int
	connections = append (connections, []int{0,1})
	connections = append (connections, []int{1,2})
	connections = append (connections, []int{2,0})
	connections = append (connections, []int{1,3})
	fmt.Println(criticalConnections(4,connections))*/
	var n,x,y int
	fmt.Scan(&n)
	xs := []int{}
	ys := []int{}
	for i:=1 ; i<=n; i++ {
		fmt.Scan(&x)
		fmt.Scan(&y)
		xs=append(xs,x)
		ys=append(ys,y)
	}
	g := NewDirectedGraph()
	for i:=1 ; i<=n; i++ {
		_, ok := g.Outs[Vertex{i}]
		if !ok {
			g.Outs[Vertex{i}] = make(map[Vertex][]Rel)
		}
		_, ok = g.Ins[Vertex{i}]
		if !ok {
			g.Ins[Vertex{i}] = []Vertex{}
		}
		for j:= i+1 ; j<=n; j++ {
			if xs[i-1]==xs[j-1] || ys[i-1]==ys[j-1] {
				//fmt.Println("!!!")
				g.Link(Vertex{i},Vertex{j},"")
				g.Link(Vertex{j},Vertex{i},"")
			}
		}
	}
	//fmt.Println(g.StronglyConnectedComponents())
	fmt.Println(len(g.StronglyConnectedComponents())-1)
}

// 217A-mic_rizal
package main

import (
    "fmt"
)

var v [110]bool
var n, ans int
var x, y [110]int

func dfs(i int) {
    v[i] = true
    for j := 0; j < n; j++ {
        if !v[j] && (x[i] == x[j] || y[i] == y[j]) {
            dfs(j)
        }
    }
}

func main() {
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&x[i], &y[i])
    }
    for i := 0; i < n; i++ {
        if !v[i] {
            dfs(i)
            ans++
        }
    }
    fmt.Println(ans - 1)
}

package main

import (
	"fmt"
)

func main() {
	n := 0
	fmt.Scanf("%d", &n)

	x, y := make([]int, n), make([]int, n)
	parent := make([]int, n)
	sz := make([]int, n)

	for i := 0; i < n; i++ {
		parent[i] = i
		sz[i] = 1
		fmt.Scanf("%d%d", &x[i], &y[i])
	}

	var find func(int) int
	find = func(a int) int {
		if parent[a] == a {
			return a
		}
		parent[a] = find(parent[a])
		return parent[a]
	}

	var unite func(int, int)
	unite = func(a, b int) {
		a = find(a)
		b = find(b)
		if a != b {
			if sz[b] > sz[a] {
				a = a ^ b
				b = a ^ b
				a = a ^ b
			}
			parent[b] = a
			sz[a] += sz[b]
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if x[i] == x[j] || y[i] == y[j] {
				unite(i, j)
			}
		}
	}

	ans := -1
	for i := 0; i < n; i++ {
		if i == find(i) {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

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

// Took from here: https://www.codementor.io/tucnak/using-golang-for-competitive-programming-h8lhvxzt3
var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 10000000)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout,10000000)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

var n, count int
var matrix [1001][1001]int

func main() {
  // STDOUT MUST BE FLUSHED MANUALLY!!!
  defer writer.Flush()

  scanf("%d\n", &n)
  for i := 1; i <= n; i++ {
    var a, b int
    scanf("%d %d\n", &a, &b)
    matrix[a][b] = 1
  }

  for i := 1; i <= 1000; i++ {
    for j := 1; j <= 1000; j++ {
      if matrix[i][j] == 1 {
        count++
        dfs_adaptada(i, j)
        break
      }
    }
  }
  printf(strconv.Itoa(count - 1))
}

func dfs_adaptada(x, y int) () {
  if matrix[x][y] == 1 {
    matrix[x][y] = 2
    for i := x + 1; i <= 1000; i++ {
      if matrix[i][y] == 1 {
        dfs_adaptada(i, y)
      }
    }
    for j := y + 1; j <= 1000; j++ {
      if matrix[x][j] == 1 {
        dfs_adaptada(x, j)
      }
    }
  }
}

package main

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

// Took from here: https://www.codementor.io/tucnak/using-golang-for-competitive-programming-h8lhvxzt3
var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 10000000)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout,10000000)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  // STDOUT MUST BE FLUSHED MANUALLY!!!
  defer writer.Flush()

  var n int
  scanf("%d\n", &n)
  var xcount [1001]int
  var ycount [1001]int
  var matrix [1001][1001]int
  for i := 1; i <= n; i++ {
    var x, y int
    scanf("%d %d\n", &x, &y)
    matrix[x][y] = 1
    xcount[x]++;
    ycount[y]++;
  }
  count := 0
  for i := 1; i <= 1000; i++ {
    for j := 1; i <= 1000; i++ {
      if matrix[i][j] == 1 && xcount[i] == 1 && ycount[j] == 1 {
        count++
      }
    }
  }
  fmt.Println(count)
}

package main

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

// Took from here: https://www.codementor.io/tucnak/using-golang-for-competitive-programming-h8lhvxzt3
var reader *bufio.Reader = bufio.NewReaderSize(os.Stdin, 10000000)
var writer *bufio.Writer = bufio.NewWriterSize(os.Stdout,10000000)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

var n, count int
var matrix [1001][1001]int

func main() {
  // STDOUT MUST BE FLUSHED MANUALLY!!!
  defer writer.Flush()

  scanf("%d %d\n", &n)
  for i := 1; i <= n; i++ {
    var a, b int
    scanf("%d %d\n", &a, &b)
    matrix[a][b] = 1
  }

  for i := 1; i <= 1000; i++ {
    for j := 1; j <= 1000; j++ {
      if matrix[i][j] == 1 {
        count++
        dfs_adaptada(i, j)
        break
      }
    }
  }
  printf(strconv.Itoa(count - 1))
}

func dfs_adaptada(x, y int) () {
  if matrix[x][y] == 1 {
    matrix[x][y] = 2
    for i := x + 1; i <= 1000; i++ {
      if matrix[i][y] == 1 {
        dfs_adaptada(i, y)
      }
    }
    for j := y + 1; j <= 1000; j++ {
      if matrix[x][j] == 1 {
        dfs_adaptada(x, j)
      }
    }
  }
}

//https://codeforces.com/problemset/problem/217/A
//http://bigocoder.com/courses/BLUE20/BLUE20_LEC16/BLUE_L16P05/statement
package main

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

var (
	rank   []int
	parent []int
)

type snowDrift struct {
	x int
	y int
}

func makeSet(n int) {
	parent = make([]int, n)

	for i := range parent {
		parent[i] = i
	}
}

func unionSet(a int, b int) {
	aParent := findSet(a)
	bParent := findSet(b)

	if aParent == bParent {
		return
	}
	if rank[aParent] > rank[bParent] {
		parent[b] = aParent
		return
	}
	if rank[aParent] < rank[bParent] {
		parent[a] = bParent
		return
	}

	parent[bParent] = aParent
	rank[aParent]++
}

func findSet(v int) int {
	if v != parent[v] {
		parent[v] = findSet(parent[v])
	}

	return parent[v]
}

func isSameSet(a snowDrift, b snowDrift) bool {
	return a.x == b.x || a.y == b.y
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, set int
	fmt.Fscanf(r, "%d\n", &n)
	rank = make([]int, n)
	drifts := make([]snowDrift, n)
	makeSet(n)

	for i := range drifts {
		fmt.Fscanf(r, "%d %d\n", &drifts[i].x, &drifts[i].y)
		for j := 0; j < i; j++ {
			if isSameSet(drifts[i], drifts[j]) {
				unionSet(i, j)
			}
		}
	}

	for i := range parent {
		if i == parent[i] {
			set++
		}
	}

	fmt.Fprintf(os.Stdout, "%d\n", set-1)
}

//https://codeforces.com/problemset/problem/217/A
//http://bigocoder.com/courses/BLUE20/BLUE20_LEC16/BLUE_L16P05/statement
package main

import "bufio"

import "os"

import "fmt"

var (
	rank   []int
	parent []int
)

type snowDrift struct {
	x int
	y int
}

func makeSet(n int) {
	parent = make([]int, n)

	for i := range parent {
		parent[i] = i
	}
}

func isSameSet(a snowDrift, b snowDrift) bool {
	return a.x == b.x || a.y == b.y
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, set int
	fmt.Fscanf(r, "%d\n", &n)
	rank = make([]int, n)
	drifts := make([]snowDrift, n)
	makeSet(n)

	for i := range drifts {
		fmt.Fscanf(r, "%d %d\n", &drifts[i].x, &drifts[i].y)
	}

	for i := range drifts {
		for j := i + 1; j < n; j++ {
			if !isSameSet(drifts[i], drifts[j]) {
				set++
			} else {
				break
			}
		}
	}

	fmt.Println(set)
}

//https://codeforces.com/problemset/problem/217/A
//http://bigocoder.com/courses/BLUE20/BLUE20_LEC16/BLUE_L16P05/statement
package main

import "bufio"

import "fmt"

import "os"

var (
	rank   []int
	parent []int
)

type snowDrift struct {
	x int
	y int
}

func makeSet(n int) {
	parent = make([]int, n)

	for i := range parent {
		parent[i] = i
	}
}

func unionSet(a int, b int) {
	aParent := findSet(a)
	bParent := findSet(b)

	if aParent == bParent {
		return
	}
	if rank[aParent] > rank[bParent] {
		parent[b] = aParent
		return
	}
	if rank[aParent] < rank[bParent] {
		parent[a] = bParent
		return
	}

	parent[b] = aParent
	rank[aParent]++
}

func findSet(v int) int {
	if v != parent[v] {
		parent[v] = findSet(parent[v])
	}

	return parent[v]
}

func isSameSet(a snowDrift, b snowDrift) bool {
	return a.x == b.x || a.y == b.y
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, set int
	fmt.Fscanf(r, "%d\n", &n)
	rank = make([]int, n)
	drifts := make([]snowDrift, n)
	makeSet(n)

	for i := range drifts {
		fmt.Fscanf(r, "%d %d\n", &drifts[i].x, &drifts[i].y)
	}

	for i := range drifts {
		for j := i + 1; j < n; j++ {
			if isSameSet(drifts[i], drifts[j]) {
				unionSet(i, j)
			}
		}
	}

	for i := range parent {
		if i == parent[i] {
			set++
		}
	}

	fmt.Fprintf(os.Stdout, "%d\n", set-1)
}

//https://codeforces.com/problemset/problem/217/A
//http://bigocoder.com/courses/BLUE20/BLUE20_LEC16/BLUE_L16P05/statement
package main

import "bufio"

import "strings"

import "fmt"

var (
	rank   []int
	parent []int
)

type snowDrift struct {
	x int
	y int
}

func makeSet(n int) {
	parent = make([]int, n)

	for i := range parent {
		parent[i] = i
	}
}

func isSameSet(a snowDrift, b snowDrift) bool {
	return a.x == b.x || a.y == b.y
}

func main() {
	r := bufio.NewReader(strings.NewReader(`4
	1 2
	1 4
	4 5
	6 3
	`))
	var n, set int
	fmt.Fscanf(r, "%d\n", &n)
	rank = make([]int, n)
	drifts := make([]snowDrift, n)
	makeSet(n)

	for i := range drifts {
		fmt.Fscanf(r, "%d %d\n", &drifts[i].x, &drifts[i].y)
	}

	for i := range drifts {
		for j := i + 1; j < n; j++ {
			if !isSameSet(drifts[i], drifts[j]) {
				set++
			} else {
				break
			}
		}
	}

	fmt.Println(set)
}

// 217A
package main

import (
	"fmt"
)

var (
	n, x, y, ans int
	f, b         [2005]int
)

func get(x int) int {
	if f[x] == x {
		return x
	}
	return get(f[x])
}
func main() {
	fmt.Scan(&n)
	for i := 1; i <= 2000; i++ {
		f[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanln(&x, &y)
		b[x] = b[y+1000]
		t1 := get(x)
		t2 := get(y + 1000)
		if t1 != t2 {
			f[t1] = t2
		}
	}
	for i := 1; i <= 2000; i++ {
		if f[i] == i && f[i] == b[i] {
			ans++
		}
	}
	fmt.Println(ans - 1)
	return
}

package main

import (
	"fmt"
)

type point struct {
	x, y int
}

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

	drifts := make(map[point]bool)
	potentials := make(map[point][]point)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		pt := point{x: x, y: y}
		for v := range drifts {
			if v.x == x || v.y == y {
				continue
			}
			for _, tmp := range [2]point{
				point{x: v.x, y: y},
				point{x: x, y: v.y},
			} {
				potentials[tmp] = append(potentials[tmp], pt, v)
			}
		}
		drifts[pt] = true
	}
	total := 0

	for len(drifts) > 0 && len(potentials) > 0 {
		best := point{}
		var max int

		for v, list := range potentials {
			if max < len(list) {
				max = len(list)
				best = v
			}
		}

		total++
		for _, v := range potentials[best] {
			delete(drifts, v)
		}
		delete(potentials, best)
	}
	fmt.Println(total)
}

package main

import (
	"fmt"
)

type point struct {
	x, y int
}

type union struct {
	next  *union
	depth int
	id    int
}

func (u *union) join(other *union) *union {
	for u.next != nil {
		u = u.next
	}
	for other.next != nil {
		other = other.next
	}
	if u == other {
		return u
	}
	if other.depth < u.depth {
		other.next = u
		return u
	} else if other.depth > u.depth {
		u.next = other
		return other
	}
	other.depth++
	u.next = other
	return other
}

func (u *union) last() *union {
	for u.next != nil {
		u = u.next
	}
	return u
}

func main() {
	var n int
	fmt.Scan(&n)
	sets := make(map[point]*union)
	verts := make(map[int][]point)
	horiz := make(map[int][]point)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		pt := point{x: x, y: y}
		sets[pt] = &union{id: i}
		verts[y] = append(verts[y], pt)
		horiz[x] = append(horiz[x], pt)

	}

	for _, list := range verts {
		x := list[0]
		for _, pt := range list {
			sets[x] = sets[x].join(sets[pt])
		}
	}
	for _, list := range horiz {
		x := list[0]
		for _, pt := range list {
			sets[x] = sets[x].join(sets[pt])
		}
	}
	result := make(map[*union]struct{})

	for _, u := range sets {
		result[u] = struct{}{}
	}
	fmt.Println(len(result) - 1)
}


package main

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

type SegTree struct {
	st []int
	lazy []int
	has []bool
	size int
	el_neutro int
}

func f(a, b int) int {
	return a+b
}

func NewSegTree(n int) *SegTree {
	t := new(SegTree)
	t.st = make([]int, 4*n)
	t.lazy = make([]int, 4*n)
	t.has = make([]bool, 4*n)
	t.size = n
	return t
}

func (t *SegTree) propagate(sti, stl, str int) {
    if t.has[sti] {
        t.st[sti] = t.lazy[sti]*(str-stl+1)
        if stl != str {
            t.lazy[sti*2 + 1] = t.lazy[sti]
            t.lazy[sti*2 + 2] = t.lazy[sti]

            t.has[sti*2 + 1] = true
            t.has[sti*2 + 2] = true
        }
        t.has[sti] = false
    }
}

func (t *SegTree) query(sti, stl, str, l, r int) int {
    t.propagate(sti, stl, str)

    if str < l || r < stl {
        return t.el_neutro
    }

    if stl >= l && str <= r {
        return t.st[sti]
    }

    mid := (str+stl)/2

    return f(t.query(sti*2+1,stl,mid,l,r),t.query(sti*2+2,mid+1,str,l,r))
}

func (t *SegTree) UpdateRange(sti, stl, str, l, r, amm int) {
    t.propagate(sti, stl, str)

    if stl >= l && str <= r {
        t.lazy[sti] = amm
        t.has[sti] = true
        t.propagate(sti, stl, str)
        return
    }

    if stl > r || str < l {
        return
    }

    mid := (stl + str)/2

    t.UpdateRange(sti*2+1,stl,mid,l,r,amm)
    t.UpdateRange(sti*2+2,mid+1,str,l,r,amm)

    t.st[sti] = f(t.st[sti*2+1],t.st[sti*2+2])
}

func (t *SegTree) PQuery(l, r int) int {
    return t.query(0,0,t.size-1,l,r)
}

func (t *SegTree) PUpdateRange(l, r, amm int){
    t.UpdateRange(0,0,t.size-1,l,r,amm);
}

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

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

func init() {
	// const maxCapacity = SIZE
	// buf := make([]byte, maxCapacity)
	// scanner.Buffer(buf, maxCapacity)
	scanner.Split(bufio.ScanWords)
}

func main() {
	defer writer.Flush()

	n := ReadInt()

	st := NewSegTree(n)

	occ := make(map[int][]int)

	for i := 0; i < n; i++ {
		st.PUpdateRange(i,i,1)
		x := ReadInt()
		occ[x] = append(occ[x], i)
	}

	for _, p := range occ {
		if len(p) >= 2 {
			st.PUpdateRange(p[0]+1, p[len(p)-1], 0)
		}
	}

	inter := st.PQuery(0, n)
	resp := int64(1)
	for i := 0; i < inter-1; i++ {
		resp = (resp*2)%998244353
	}

    writer.WriteString(strconv.FormatInt(resp, 10))
}

package main

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

func mmod(n int64, d int64) int64 {
	var mod int64 = 998244353
	var ans int64 = 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = (ans * d) % mod
		}
		d = (d * d) % mod
		n >>= 1
	}
	return ans
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d\n", &n)
	//fmt.Printf("n=%d\n",n)
	mat := make([]int, n+1)
	wmap := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
		wmap[mat[i]] = i
	}

	var mi int64 = 0
	var front int = 0
	for front < n {
		p := front
		for p < n && p <= front {
			if front < wmap[mat[p]] {
				front = wmap[mat[p]]
			}
			p++
		}
		front++
		mi++
	}
//	fmt.Printf("mi=%d\n",mi)
	fmt.Printf("%d\n",mmod(mi-1,2))
}

package main

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

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

func Sol1102E(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	arr := make([]int, n)
	rightI := make(map[int]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
		rightI[arr[i]] = i
	}

	ans := 1
	for l, r := 0, 0; r < n; {
		checkVal := arr[r]
		for i := l; i < rightI[checkVal]; i++ {
			r = max(r, rightI[arr[i]])
			checkVal = arr[r]
		}
		if r+1 == n {
			break
		}
		ans = (ans << 1) % 998244353
		l = rightI[checkVal] + 1
		r++
	}
	Fprintln(out, ans)
}

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

package main

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

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

func Sol1102E(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	arr := make([]int, n)
	rightI := make(map[int]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
		rightI[arr[i]] = i
	}

	ans := 1
	for l, r := 0, 0; r < n; {
		checkVal := arr[r]
		for _, val := range arr[l:rightI[checkVal]] {
			r = max(r, rightI[val])
		}
		if r+1 == n {
			break
		}
		ans = (ans << 1) % 998244353
		l = rightI[checkVal] + 1
		r++
	}
	Fprintln(out, ans)
}

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


package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		readLine(reader)
		line := readLine(reader)
		ai := strings.Split(string(line), " ")
		arr := make([]int, len(ai)+1)
		arr[0] = 0
		arr[1] = 1
		for i := 2; i <= len(ai); i++ {
			last, _ := strconv.ParseInt(ai[i-2], 10, 64)
			if last == 1 {
				arr[i] = arr[i-2]
			} else {
				arr[i] = arr[i-1]
			}
		}
		if arr[len(ai)] == 1 {
			fmt.Println("First")
		} else {
			fmt.Println("Second")
		}
	}
}

const str = "abacaba"

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		a := io.nextInts(n)

		win := 0
		for i := n - 2; i >= 0; i-- {
			if a[i] == 1 {
				win ^= 1
			} else {
				win = 0
			}
		}
		if win == 0 {
			io.println("First")
		} else {
			io.println("Second")
		}
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

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

func main() {
	var t int
	fmt.Scan(&t)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	for i := 0; i < t; i++ {
		scanner.Scan()
		n := toInt(scanner.Bytes())
		fir := -1
		// in := make([]int, n)

		for j := 1; j <= n; j++ {
			scanner.Scan()
			// in[j] = toInt(scanner.Bytes())
			z := toInt(scanner.Bytes())
			if (z != 1) && (fir == -1) {
				fir = j - 1
			}
		}
		if fir == -1 {
			if ok := n & 1; ok == 1 {
				fmt.Println("First")
			} else {
				fmt.Println("Second")
			}
		} else {
			if ok := fir & 1; ok == 1 {
				fmt.Println("Second")
			} else {
				fmt.Println("First")
			}
		}

	}
}

func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

func main() {
	var t int
	fmt.Scan(&t)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	for i := 0; i < t; i++ {
		scanner.Scan()
		n := toInt(scanner.Bytes())
		in := make([]int, n)

		for j := 0; j < n; j++ {
			scanner.Scan()
			in[j] = toInt(scanner.Bytes())
		}
		flag := true
	Loop:
		for _, v := range in {
			if v == 0 {
				continue Loop
			}
			if v == 1 {
				v = 0
				flag = !flag
				continue Loop
			}
			for {
				if v == 0 {
					break
				}
				if v == 1 {
					v = 0
					flag = !flag
					continue Loop
				} else {
					flag = !flag
					break Loop
				}
			}
		}
		if flag {
			fmt.Println("Second")
		} else {
			fmt.Println("First")
		}

	}
}

func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
		a := make([]int64, n)
		for i := range a {
			a[i] = sint64()
		}
		printf("%s\n", sol(a))
	}
}

func sol(a []int64) string {
	winner := 0
	p := 0
	for p < len(a) {
		if a[p] == 1 {
			winner ^= 1
			p++
			continue
		}
		break
	}
	if p == len(a) {
		winner ^= 1
	}
	if winner == 1 {
		return "Second"
	}
	return "First"
}


package main

import (
	"fmt"
)

func sort(size int, arr []int) int {

	if size > 2 {
		half := size / 2
		left_half := sort(half, arr[:half])
		right_half := sort(half, arr[half:])
		if left_half == half && right_half == half && arr[half-1] <= arr[half] {
			return right_half + left_half

		} else if left_half == 1 && right_half == 1 {
			return 1
		} else if left_half < right_half {
			return right_half
		} else if left_half > right_half {
			return left_half
		} else {
			return right_half
		}

	} else {

		if arr[0] <= arr[1] {
			return 2
		} else {
			return 1
		}
	}

}

func main() {

	var n int
	fmt.Scanf("%d\n", &n)
	inputdata := make([]int, n)
	for i, _ := range inputdata {
		fmt.Scanf("%d", &inputdata[i])
	}

	if n <= 1 {
		fmt.Println(n)
	} else {
		fmt.Println(sort(n, inputdata))
	}

}

package main

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

func thanos(arr[] int64) int {
	length := len(arr)
	possible := 1
	flag := true
	i :=0
	for ; i < length-1; i++ {
		if arr[i] > arr[i+1] {
			flag = false
			break
		}
		possible++
	}
	if flag == true {
		return possible
	} else {
		return int(math.Max(float64(thanos(arr[0: (length/2)])), float64(thanos(arr[(length/2): length]))))
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _, _ := reader.ReadLine()
	length, err := strconv.ParseInt(string(line[0:]), 10, 0)
	if err != nil {
		fmt.Printf("err %v", err)
	}
	data := make([]int64, length)
	x, _, _ := reader.ReadLine()
	x1 := strings.Split(string(x[0:]), " ")
	for i := 0; i < int(length); i++ {
		data[i], _ = strconv.ParseInt(x1[i], 10, 0)
	}
	n := thanos(data)
	fmt.Printf("%d", n)

}

package main

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

var res []int
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func max(array []int) {
	var max int = array[0]
	for _, value := range array {
		if max < value {
			max = value
		}
	}
	printf("%d", max)
}

func checkSort( size int, inputArray []int) {
	for i:=0; i<size-1;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			checkSort(size, inputArray)
			checkSort(size, inputArray[size:])
			return
		}
	}
	res = append(res, size)
}

func main() {
	defer writer.Flush()
	var size int

	fmt.Scan(&size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	checkSort(size, inputArray)
	max(res)

}

package main

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

func main() {
	inputreader := bufio.NewReader(os.Stdin)
	var str string
	str,_= inputreader.ReadString('\n')
	str=strings.TrimSpace(str)
	temp:=strings.Split(str," ")
	N,_:= strconv.Atoi(temp[0])
	arr:=make([]int,N)
	str,_= inputreader.ReadString('\n')
	str=strings.TrimSpace(str)
	temp=strings.Split(str," ")
	for i:=0;i<N;i++{
		arr[i],_= strconv.Atoi(temp[i])
	}

fmt.Println(isSorted(arr,0,N-1))

}
func isSorted(arr[]int,start,end int)int{
	if end==start{
		return 1
	}
	check:=true
	for i:=start;i<end;i++{
		if arr[i]>arr[i+1]{
			check=false
			break
		}
	}
  if check{
  	return end-start+1
  }
	mid:=(start+end)/2
	return max(isSorted(arr,start,mid),isSorted(arr,mid+1,end))

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

package main

import (
	"fmt"
	"sort"
)

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

func dfs(s []int) int {
	// fmt.Println("[d01] dfs en: s", s)
	ok := true
	if len(s) == 1 {
		return len(s)
	}
	t := make([]int, len(s))
	copy(t, s)
	sort.Ints(t)
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			ok = false
			break
		}
	}
	if ok {
		return len(s)
	}
	return max(dfs(s[:len(s)/2]), dfs(s[len(s)/2:]))
}

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

package main

import "fmt"

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

func sorted(arr []int) bool {
	for i := 1; i < len(arr); i++ {
		if arr[i-1] > arr[i] {
			return false
		}
	}
	return true
}

func thanos(arr []int) int {
	if sorted(arr) {
		return len(arr)
	}

	return max(thanos(arr[:len(arr)/2]), thanos(arr[len(arr)/2:]))
}

func main() {
	var n int
	var arr []int

	fmt.Scanf("%d\n", &n)
	arr = make([]int, n)

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

	fmt.Println(thanos(arr))
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	last := 0
	min := 0
	high := int(math.Log2(float64(n))) + 1

	var states = make([]bool, high)

	for i := 0; i < n; i++ {
		var cur int
		_, _ = fmt.Scanf("%d", &cur)

		if last == 0 {
			last = cur
			continue
		}

		for j:= min; j < high; j++ {
			q := 1 << uint(j)
			if i % q == 0 {

				if ! states[j] {
					min = j
				}
				states[j] = false

			} else {
				states[j] = states[j] || last > cur
			}
		}

		last = cur
	}

	for j:= min; j < high; j++ {
		if ! states[j] {
			min = j
		}
	}

	fmt.Print(1 << uint(min))
}

package main

import "fmt"

func main(){
	//获取输入参数
	var n int
	var arr []int
	fmt.Scanln(&n)

	for i := 1; i <= n; i++{
		var num int
		if(i != n){
			fmt.Scanf("%d", &num)
		} else {
			fmt.Scanln(&num)
		}
		arr = append(arr, num)
	}

	size := getSize(0, n - 1, arr)
	fmt.Println(size)
}

func getSize(begin int, end int, arr []int) int {
	if beOrder(begin, end, arr) {
		return end - begin + 1
	} else if begin < end - 1 {
		half := (end - begin) / 2 + begin
		sub1 := getSize(begin, half, arr)
		sub2 := getSize(half + 1, end, arr)
		if sub1 > sub2 {
			return sub1
		} else {
			return sub2
		}
	} else {
		return 1
	}

}

//判断是否有序
func beOrder(begin int, end int, arr []int) bool {
	if(begin >= end) {
		return true
	}
	for i := begin + 1; i <= end; i++ {
		if arr[i] < arr[i - 1] {
			return false
		}
	}
	return true
}

package main

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

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

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

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

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return 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...)
}

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

// Simple math functions

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 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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

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

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

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

func main() {
	defer Flush()

	n := readi()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	println(dfs(a, 0, n))
}

func dfs(a []int, l, r int) int {
	if sort.IsSorted(sort.IntSlice(a[l:r])) {
		return r - l
	}
	m := (l + r) / 2
	return max(dfs(a, l, m), dfs(a, m, r))
}

package main

import "fmt"

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

func f(a []int, start int, end int) int {
	ok := true
	for i := start; i <= end-1; i++ {
		if a[i] > a[i+1] {
			ok = false
			break
		}
	}
	if ok {
		return end - start + 1
	} else {
		mid := (start + end) / 2
		return Max(f(a, start, mid), f(a, mid+1, end))
	}
}

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

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

	fmt.Println(f(a, 0, n-1))
}

package main

import (
. "fmt"
)

const MAXN = 20
var arr [MAXN]int

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

func maks(l int, r int) int {
    gagal := false
    for i := l+1; i <= r; i++ {
        if arr[i-1] > arr[i] {
            gagal = true
        }
    }
    if !gagal {
        return r-l+1
    } else {
        return Max(maks(l, (l+r)/2), maks((l+r)/2+1, r))
    }
}

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

    for i := 0; i < N; i++ {
        Scan(&arr[i])
    }
    Println(maks(0, N-1))
}

package main

import (
        "fmt"
        "sort"
)

var num int

func main() {
        fmt.Scanln(&num)
        a := make([]int, num)
        for i := 0; i < num; i++ {
                fmt.Scan(&a[i])
        }
        for i := num; i >= 1; i /= 2 {
                for j := 0; j < num; j += i {
                        if sort.IntsAreSorted(a[j : j+i]) {
                                fmt.Println(i)
                                return
                        }
                }
        }
}

package main

import (
	"fmt"
	"sort"
)

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

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

	for partSize := n; partSize >= 1; partSize /= 2 {
		for seqStart := 0; seqStart < n; seqStart += partSize {
			if sort.IntsAreSorted(a[seqStart:seqStart + partSize]) {
				fmt.Println(partSize)
				return
			}
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	input := make([]string, 0)
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	n, err := strconv.Atoi(input[0])
	if err != nil {
		log.Fatal(err)
	}
	arrayStrings := strings.Split(input[1], " ")
	array := make([]int, n)
	for index, item := range arrayStrings {
		array[index], _ = strconv.Atoi(item)
	}
	fmt.Println(getSortedLen(array))
}

func getSortedLen(array []int) int {
	if sort.SliceIsSorted(array, func(p, q int) bool {
		return array[p] < array[q]
	}) {
		return len(array)
	}
	left := getSortedLen(array[:len(array)/2])
	right := getSortedLen(array[len(array)/2:])
	if left > right {
		return left
	}
	return right
}

package main

import (
	"fmt"
)

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

func solve( tmp []int) int{
	l := len(tmp)

	if l <= 1{
		return 1
	}

	if l == tmp[l-1]-tmp[0]+1{
		return l
	}
	return max(solve(tmp[0:l/2]), solve(tmp[l/2:]))
}

func main(){
	n := 0
	fmt.Scan(&n)
	arr := make([]int, n)
	tmp := make([]int, n)

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

	if n == 0 || n == 1{
		fmt.Println(n)
		return
	}

	for i:=0; i < n; i++{
		tmp[i] = 1
		if i != 0 && arr[i-1] <= arr[i]{
			tmp[i] = tmp[i-1] + tmp[i]
		}
	}
	// for i, val :=range tmp{
	//  	fmt.Printf("%d ----> %d\n", i, val)
	//  }
	fmt.Println(solve(tmp[0:]))
}

package main

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

func main() {

	scan := bufio.NewScanner(os.Stdin)

	scan.Scan()
	scan.Text()

	scan.Scan()
	txt := strings.Fields(scan.Text())

	var nums []int

	for _, v := range txt {

		sc, _ := strconv.Atoi(v)
		nums = append(nums, sc)
	}

	for i := 1; i < len(nums); i++ {

		if nums[i-1] > nums[i] {

			if cut := len(nums) / 2; i-1 < cut {
				nums = append(nums[cut:])
			} else {
				nums = append(nums[:cut])
			}
			i = 0
		}
	}

	fmt.Print(len(nums))
}

package main

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

var a [16]int

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0;i < n - 1;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
	}
	fmt.Fscanf(reader, "%d", &a[n - 1])
	for i := n;i > 0; i = i >> 1 {
		for j := 0;j < n;j += i {
			inc := true
			for k := j;k < j + i - 1;k ++ {
				if a[k] > a[k + 1] {
					inc = false
				}
			}
			if inc {
				fmt.Printf("%d", i)
				return
			}
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	arr := make([]int, n)

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

	c, _ := thanosCount(arr, 0, n-1)
	fmt.Println(c)
}

func thanosCount(a []int, l, r int) (int, bool) {
	if r == l {
		return 1, true
	}
	if r == l+1 {
		if a[l] <= a[r] {
			return 2, true
		} else {
			return 1, false
		}
	}

	mid := (l + r) / 2

	lc, lb := thanosCount(a, l, mid)
	rc, rb := thanosCount(a, mid+1, r)

	if lb && rb && a[mid] <= a[mid+1] {
		return lc + rc, true
	}
	if lc > rc {
		return lc, false
	} else {
		return rc, false
	}
}

package main

import "fmt"

func main() {
	var sliceLen int
	slice := make([]int, 0, 100)
	var tmp int

	fmt.Scanf("%d\r", &sliceLen)
	for i := 0; i < sliceLen; i++ {
		fmt.Scanf("%d", &tmp)
		slice = append(slice, tmp)
	}

	fmt.Println(thanosSort(sliceLen, slice))
}

func thanosSort(sliceLen int, slice []int) int {
	if sliceLen == 1 {
		return 1
	}

	if isSorted(sliceLen, slice) {
		return sliceLen
	}

	newSliceLen := sliceLen / 2
	sortLenLeft := thanosSort(newSliceLen, slice[:newSliceLen])
	sortLenRight := thanosSort(newSliceLen, slice[newSliceLen:])

	if sortLenLeft > sortLenRight {
		return sortLenLeft
	}
	return sortLenRight

}

func isSorted(n int, slice []int) bool {
	for i := 1; i < n; i++ {
		if slice[i] < slice[i-1] {
			return false
		}
	}
	return true
}

package main

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

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

func thanosSort(nums []int, i int, j int) int {
	if i >= j {
		return 1
	}
	curMax := 1
	for ii := i; ii < j; ii++ {
		if nums[ii] > nums[ii+1] {
			curMax = 0
			break
		}
		curMax++
	}
	mid := i + (j-i)/2
	leftMax := thanosSort(nums, i, mid)
	rightMax := thanosSort(nums, mid+1, j)
	return max(curMax, max(leftMax, rightMax))
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	nums := scanner.Text()
	numsSlice := strings.Split(nums, " ")
	var numbers []int
	for _, v := range numsSlice {
		val, _ := strconv.Atoi(v)
		numbers = append(numbers, val)
	}
	if size == 0 || size == 1 {
		fmt.Println(1)
		return
	}
	fmt.Println(thanosSort(numbers, 0, size-1))
}

package main

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

var ans = 1

func main() {
	var n int
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	_, _ = fmt.Sscanf(scanner.Text(), "%d", &n)
	mySlice := make([]int, n)
	scanner.Scan()
	numbersAsString := strings.Split(scanner.Text(), " ")
	for i, v := range numbersAsString {
		mySlice[i], _ = strconv.Atoi(v)
	}
	checkSlice(mySlice)
	fmt.Println(ans)
}

func checkSlice(mySlice []int) {
	if checkIsSorted(mySlice) {
		if len(mySlice) > ans {
			ans = len(mySlice)
		}
	} else {
		firstHalf := mySlice[:len(mySlice)/2]
		//fmt.Println("checking : ", firstHalf)
		checkSlice(firstHalf)
		secondHalf := mySlice[len(mySlice)/2:]
		//fmt.Println("checking 2 : ", secondHalf)
		checkSlice(secondHalf)
	}
}
func checkIsSorted(numbers []int) bool {
	result := true
	for i, v := range numbers {
		if i != len(numbers)-1 {
			if v > numbers[i+1] {
				result = false
			}
		}
	}
	return result
}

package main

import (
	"fmt"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}
var lent =0
func thanos (arr []int){
	if isSorted(arr){
		if len(arr)>lent{
			lent=len(arr)
		}
		return
	}
	left:=arr[:(len(arr)/2)]
	right:=arr[(len(arr)/2):]
		thanos(left)
	thanos(right)
}
func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	thanos(arr)
	fmt.Println(lent)

}

package main

import (
	"fmt"
)

func main() {

	var length int
	fmt.Scanf("%d", &length)

	numbers := make([]int, length)

	for i := range numbers {
		fmt.Scan(&numbers[i])
	}

	fmt.Print(thanos(numbers))
}

func thanos(numbers []int) int {
	if checkSort(numbers) {
		return len(numbers)
	}

	return max(
		thanos(numbers[:(len(numbers) / 2)]),
		thanos(numbers[(len(numbers) / 2):]),
	)
}

func checkSort(numbers []int) bool {
	if len(numbers) <= 1 {
		return true
	}

	for i := 1; i < len(numbers); i++ {
		if numbers[i] < numbers[i-1] {
			return false
		}
	}

	return true
}

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

	return a
}

package main

import "fmt"

func isSorted(arr []int) bool {
	for i := 1; i < len(arr); i++ {
		if arr[i] < arr[i-1] {
			return false
		}
	}
	return true
}

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

func GetMaxSortedArrLength(arr []int) int {
	if len(arr) <= 1 {
		return len(arr)
	}

	if isSorted(arr) {
		return len(arr)
	}

	return max(GetMaxSortedArrLength(arr[0:len(arr)/2]),
		GetMaxSortedArrLength(arr[len(arr)/2:len(arr)]))
}

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	// arr := []int{11, 12, 1, 2, 13, 14, 3, 4}
	res := GetMaxSortedArrLength(arr)
	fmt.Println(res)
}

package main

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

var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func checkSort(begin int, size int, inputArray []int) int {
	for i:=0; i<size-1;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			checkSort(0, size/2, inputArray)
			checkSort( size/2,size, inputArray)
		}
	}
	return size
}

func main() {
	defer writer.Flush()
	var size int

	fmt.Scan(&size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	size = checkSort(0,size, inputArray)
	printf("%d", size)
}

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 size int

	scanf("%d", &size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	for i:=0; i<size-2;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			i = 0
		}
	}
	printf("%d", size)
}

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 main() {
	defer writer.Flush()
	var size int

	fmt.Scan(&size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	for i:=0; i<size-1;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			i = 0
		}
	}
	if inputArray[0] > inputArray[size-1] {
		size /=2
	}
	printf("%d", size)
}

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 main() {
	defer writer.Flush()
	var size int

	fmt.Scan(&size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	for i:=0; i<size-2;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			i = 0
		}
	}
	printf("%d", size)
}

package main

import "fmt"

func main()  {
	var size int
	var j int
	fmt.Scanln(&size)

	slice := make([]int, 0)
	for i:=0;i<size; i++ {
		fmt.Scanln(&j)
		slice = append(slice, j)
	}
	for i:=0;i<size-2;i++{
		if slice[i] > slice[i+1]{
			size /= 2
			i = 0
		}
	}
	fmt.Println(size)
}

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 size int

	scanf("%d", &size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	for i:=0; i<size-2;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			i = 0
		}
	}
	println(size)
}

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 size int

	scanf("%d", &size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	for i:=0; i<size-2;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			i = 0
		}
	}
	//
	printf("%d", size)
}

package main

import "fmt"

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

func thanos(arr []int) int {
	for n := len(arr); n > 0; n /= 2 {
		small := 0
		step := len(arr) / n
		var i = 0

		for i = 0; i < len(arr); i += step {
			if min(arr[i:i+step]) < small {
				break
			}
			small = min(arr[i : i+step])
		}

		if i >= len(arr) {
			return n
		}
	}

	return 1
}

func main() {
	var n int
	var arr []int

	fmt.Scanf("%d", &n)
	arr = make([]int, n)

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

	fmt.Println(thanos(arr))
}

package main

import "fmt"

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

func thanos(arr []int) int {
	for n := len(arr); n > 0; n /= 2 {
		small := 0
		step := len(arr) / n
		var i = 0

		for i = 0; i < len(arr); i += step {
			if min(arr[i:i+step]) < small {
				break
			}
			small = min(arr[i : i+step])
		}

		if i >= len(arr) {
			return n
		}
	}

	return 1
}

func main() {
	var n int
	var arr []int

	fmt.Scanf("%d\n", &n)
	arr = make([]int, n)

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

	fmt.Println(thanos(arr))
}

package main

import "fmt"

const inf = 101

func min(small int, arr []int) int {
	res := inf
	for i := 0; i < len(arr); i++ {
		if arr[i] < res && arr[i] >= small {
			res = arr[i]
		}
	}

	if res == inf {
		return -1
	}
	return res
}

func thanos(arr []int) int {
	for n := len(arr); n > 0; n /= 2 {
		small := 0
		step := len(arr) / n
		var i = 0

		for i = 0; i < len(arr); i += step {
			newSmall := min(small, arr[i:i+step])
			if newSmall < small {
				break
			}
			small = newSmall
		}

		if i >= len(arr) {
			return n
		}
	}

	return 1
}

func main() {
	var n int
	var arr []int

	fmt.Scanf("%d\n", &n)
	arr = make([]int, n)

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

	fmt.Println(thanos(arr))
}

package main

import (
	"flag"
	"fmt"
	"math"
	"os"
)

var inHandle *os.File

var quads = []int{
	0,
	1,
	2,
	4,
	8,
	16,
	32,
	64,
	128,
	256,
	512,
	1024,
	2048,
	4096,
	8192,
	16384,
	32768,
	65536,
}

func main() {
	initialize()

	n := readInt()
	last := 0
	min := 1
	high := int(math.Log2(float64(n))) + 1

	var states [17]bool

	for i := 0; i < n; i++ {
		cur := readInt()
		if last == 0 {
			last = cur
			continue
		}

		for j:= min; j < high; j++ {
			q := quads[j]
			if i % q == 0 {

				if ! states[j] {
					min = j
				}
				states[j] = false

			} else {
				states[j] = states[j] || last > cur
			}
		}

		last = cur
	}

	for j:= min; j < high; j++ {
		if ! states[j] {
			min = j
		}
	}

	fmt.Print(quads[min])
}

func initialize() {
	fileName := flag.String("in", "", "")
	flag.Parse()

	if "" == *fileName {
		inHandle = os.Stdin
	} else {
		var err error
		inHandle, err = os.Open(*fileName)
		if err != nil {
			panic(err)
		}
	}
}

func readInt() int {
	var i int
	_, _ = fmt.Fscanf(inHandle, "%d", &i)
	return i
}

package main

import (
	"flag"
	"fmt"
	"math"
	"os"
)

var inHandle *os.File

var quads = []int{
	0,
	1,
	2,
	4,
	8,
	16,
	32,
	64,
	128,
	256,
	512,
	1024,
	2048,
	4096,
	8192,
	16384,
	32768,
	65536,
}

func main() {
	initialize()

	n := readInt()
	last := 0
	min := 1
	high := int(math.Log2(float64(n))) + 1

	var states [17]bool

	for i := 0; i < n; i++ {
		cur := readInt()
		if last == 0 {
			last = cur
			continue
		}

		for j:= min; j <= high; j++ {
			q := quads[j]
			if i % q == 0 {

				if ! states[j] {
					min = j
				}
				states[j] = false

			} else {
				states[j] = states[j] || last > cur
			}
		}

		last = cur
	}

	for j:= min; j <= high; j++ {
		if ! states[j] {
			min = j
		}
	}

	fmt.Print(quads[min])
}

func initialize() {
	fileName := flag.String("in", "", "")
	flag.Parse()

	if "" == *fileName {
		inHandle = os.Stdin
	} else {
		var err error
		inHandle, err = os.Open(*fileName)
		if err != nil {
			panic(err)
		}
	}
}

func readInt() int {
	var i int
	_, _ = fmt.Fscanf(inHandle, "%d", &i)
	return i
}

package main

import (
	"flag"
	"fmt"
	"math"
	"os"
)

func main() {
	initialize()

	n := readInt()
	v := make([]int, n)

	for i := 0; i < n; i++ {
		v[i] = readInt()
	}

	h := uint(math.Log2(float64(n))) + 1

LOOP:
	for i := uint(1); i <= h; i++ {
		d := n / (1 << (i - 1))
		for j := 0; j < n; j += d {
			last := v[j]
			sort := true
			for k := j + 1; k < j+d; k++ {
				if last > v[k] {
					sort = false
					break
				} else {
					last = v[k]
				}
			}

			if (sort) {
				fmt.Print(d)
				break LOOP
			}
		}
	}
}

var inHandle *os.File

func initialize() {
	fileName := flag.String("in", "", "")
	flag.Parse()

	if "" == *fileName {
		inHandle = os.Stdin
	} else {
		var err error
		inHandle, err = os.Open(*fileName)
		if err != nil {
			panic(err)
		}
	}
}

func readInt() int {
	var i int
	_, _ = fmt.Fscanf(inHandle, "%d", &i)
	return i
}

package main

import (
	"flag"
	"fmt"
	"math"
	"os"
)

var inHandle *os.File

var quads = []int{
	0,
	1,
	2,
	4,
	8,
	16,
}

func main() {
	initialize()

	n := readInt()
	last := 0
	min := 1
	high := int(math.Log2(float64(n))) + 1

	var states [6]bool

	for i := 0; i < n; i++ {
		cur := readInt()
		if last == 0 {
			last = cur
			continue
		}

		for j:= min; j <= high; j++ {
			q := quads[j]
			if i % q == 0 {

				if ! states[j] {
					min = j
				}
				states[j] = false

			} else {
				states[j] = states[j] || last > cur
			}
		}

		last = cur
	}

	for j:= min; j <= high; j++ {
		if ! states[j] {
			min = j
		}
	}

	fmt.Print(quads[min])
}

func initialize() {
	fileName := flag.String("in", "", "")
	flag.Parse()

	if "" == *fileName {
		inHandle = os.Stdin
	} else {
		var err error
		inHandle, err = os.Open(*fileName)
		if err != nil {
			panic(err)
		}
	}
}

func readInt() int {
	var i int
	_, _ = fmt.Fscanf(inHandle, "%d", &i)
	return i
}

package main

import "fmt"

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

func f(a []int, start int, end int) int {
	ok := true
	for i := start; i <= end-1; i++ {
		if a[i] > a[i+1] {
			ok = false
			break
		}
	}
	if ok {
		return end - start + 1
	} else {
		mid := (start + end) / 2
		return Max(f(a, start, mid), f(a, mid+1, end))
	}
}

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

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

	fmt.Println(f(a, 0, n-1))
}

package main

import "fmt"

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

func f(a []int, start int, end int) int {
	ok := true
	for i := start; i <= end-1; i++ {
		if a[i] > a[i+1] {
			ok = false
			break
		}
	}
	if (ok) {
		return end - start + 1
	} else {
		mid := (start + end) / 2
		return Max(f(a, start, mid), f(a, mid+1, end))
	}
}

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

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

	fmt.Println(f(a, 0, n-1))
}

package main

import "fmt"

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

func f(a []int, start int, end int) int {
	up := 0
	down := 0
	for i := start; i <= end-1; i++ {
		if a[i] > a[i+1] {
			up = 1
		} else if a[i] < a[i + 1] {
			down = 1
		}
	}
	if up + down < 2 {
		return end - start + 1
	} else {
		mid := (start + end) / 2
		return Max(f(a, start, mid), f(a, mid+1, end))
	}
}

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

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

	fmt.Println(f(a, 0, n-1))
}

package main

import (
        "fmt"
        "sort"
)

func main() {
                var num int
        fmt.Scanln(&num)
        a := make([]int, num)
        for i := 0; i < num; i++ {
                fmt.Scanln(&a[i])
        }
        for i:= num; i>=1; i/=2 {
                for j := 0; j < num; j+= i{
                        if sort.IntsAreSorted(a[j:j+i]) {
                                fmt.Println(i)
                                return
                        }
                }
        }
}

package main

import (
        "fmt"
        "sort"
)

var num int

func main() {
        fmt.Scanln(&num)
        a := make([]int, num)
        for i := 0; i < num; i++ {
                fmt.Scanln(&a[i])
        }
        for i:= num; i>=1; i/=2 {
                for j := 0; j < num; j+= i{
                        if sort.IntsAreSorted(a[j:j+i]) {
                                fmt.Println(i)
                                return
                        }
                }
        }
}

package main

import (
	"fmt"
)

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

func solve( tmp []int) int{
	l := len(tmp)

	if l == 1{
		return 1
	}

	if l == tmp[l-1]{
		return l
	}
	return max(solve(tmp[0:l/2]), solve(tmp[l/2:]))
}

func main(){
	n := 0
	fmt.Scan(&n)
	arr := make([]int, n)
	tmp := make([]int, n)

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

	if n == 0 || n == 1{
		fmt.Println(n)
	}

	for i:=0; i < n; i++{
		tmp[i] = 1
		if i != 0 && arr[i-1] <= arr[i]{
			tmp[i] = tmp[i-1] + tmp[i]
		}
	}
	// for i, val :=range tmp{
	// 	fmt.Printf("%d ----> %d\n", i, val)
	// }
	fmt.Println(solve(tmp[0:n]))
}

package main

import (
	"fmt"
)

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

func solve( tmp []int) int{
	l := len(tmp)

	if l == 1{
		return 1
	}

	if l == tmp[l-1]{
		return l
	}
	return max(solve(tmp[0:l/2]), solve(tmp[l/2:]))
}

func main(){
	n := 0
	fmt.Scan(&n)
	arr := make([]int, n)
	tmp := make([]int, n)

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

	if n == 0 || n == 1{
		fmt.Println(n)
		return
	}

	for i:=0; i < n; i++{
		tmp[i] = 1
		if i != 0 && arr[i-1] <= arr[i]{
			tmp[i] = tmp[i-1] + tmp[i]
		}
	}
	// for i, val :=range tmp{
	// 	fmt.Printf("%d ----> %d\n", i, val)
	// }
	fmt.Println(solve(tmp[0:n]))
}

package main

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

func main() {

	scan := bufio.NewScanner(os.Stdin)

	scan.Scan()
	scan.Text()

	scan.Scan()
	txt := strings.Fields(scan.Text())

	var nums []int

	for _, v := range txt {

		sc, _ := strconv.Atoi(v)
		nums = append(nums, sc)
	}

	for i := 1; i < len(nums); i++ {

		if nums[i-1] > nums[i] {

			if cut := len(nums) / 2; i-1 >= cut {
				nums = append(nums[cut:])
			} else {
				nums = append(nums[:cut])
			}
			i = 0
		}
	}

	println(len(nums))
}

package main

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

func main() {

	scan := bufio.NewScanner(os.Stdin)

	scan.Scan()
	scan.Text()

	scan.Scan()
	txt := strings.Fields(scan.Text())

	var nums []int

	for _, v := range txt {

		sc, _ := strconv.Atoi(v)
		nums = append(nums, sc)
	}

	for i := 1; i < len(nums); i++ {

		if nums[i-1] > nums[i] {

			if cut := len(nums) / 2; i-1 >= cut {
				nums = append(nums[cut:])
			} else {
				nums = append(nums[:cut])
			}
			i = 0
		}
	}

	fmt.Print(len(nums))
}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		rand.Seed(time.Now().UnixNano())
		y:=rand.Float64()
		fmt.Println(y)

		if len(arr)%2 !=0 {
			if y<0.5{
				arr=arr[:(len(arr)+1)/2]
			}else {
				arr=arr[(len(arr)+1)/2:]
			}
		}else {
			if y<0.5{
				arr=arr[:len(arr)/2]
			}else {
				arr=arr[len(arr)/2:]
			}
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		x:=(rand.Intn(10))
		if x<5{
			arr=arr[:len(arr)/2]
		}else {
			arr=arr[len(arr)/2:]
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		rand.NewSource(time.Now().UnixNano())
		y:=rand.Float64()
		fmt.Println(y)
		if y<0.5{
			arr=arr[:len(arr)/2]
		}else {
			arr=arr[len(arr)/2:]
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		x:=(rand.NewSource(time.Now().UnixNano()))
		r:=rand.New(x)
		if r.Intn(10)<5{
			arr=arr[:len(arr)/2]
		}else {
			arr=arr[len(arr)/2:]
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		rand.NewSource(time.Now().UnixNano())
		y:=rand.Float64()
		if y<0.5{
			arr=arr[:len(arr)/2]
		}else {
			arr=arr[len(arr)/2:]
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		if rand.Float64()<0.5{
			arr=arr[:len(arr)/2]
		}else {
			arr=arr[len(arr)/2:]
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func isSorted(arr []int )bool  {
	for i:=0;i<len(arr)-1 ;i++  {
		if arr[i]>arr[i+1]{
			return false
		}else {
			continue
		}
	}
	return true
}

func main() {
	var size int
	var arr []int
	fmt.Scan(&size)
	var in int
	for i:=0;i<size ;i++  {
			fmt.Scan(&in)
			arr =append(arr,in)
	}
	for !isSorted(arr)  {
		x:=rand.NewSource(time.Now().UnixNano())
		g:=rand.New(x)
		y:=g.Intn(10)

		if len(arr)%2 !=0 {
			if y<5{
				arr=arr[:(len(arr)+1)/2]
			}else {
				arr=arr[(len(arr)+1)/2:]
			}
		}else {
			if y<5{
				arr=arr[:len(arr)/2]
			}else {
				arr=arr[len(arr)/2:]
			}
		}
	}
	fmt.Println(len(arr))
}

package main

import (
	"fmt"
)

func do(numbers []int) int {
	if checkSort(numbers) {
		return len(numbers)
	}

	left := do(numbers[:len(numbers)-1])
	right := do(numbers[len(numbers)-1:])

	if left > right {
		return left
	}

	return right
}

func checkSort(numbers []int) bool {
	if len(numbers) == 1 {
		return true
	}

	for i := 1; i < len(numbers); i++ {
		if numbers[i] < numbers[i-1] {
			return false
		}
	}

	return true
}

func main() {

	var length int
	fmt.Scanf("%d", &length)

	numbers := make([]int, length)

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

	fmt.Print(do(numbers))
}

package main

import (
	"fmt"
)

func do(numbers []int) int {
	if checkSort(numbers) {
		return len(numbers)
	}

	left := do(numbers[:len(numbers)-1])
	right := do(numbers[len(numbers)-1:])

	if left > right {
		return left
	}

	return right
}

func checkSort(numbers []int) bool {
	if len(numbers) == 1 {
		return true
	}

	for i := 1; i < len(numbers); i++ {
		if numbers[i] < numbers[i-1] {
			return false
		}
	}

	return true
}

func main() {

	var length int
	fmt.Scanf("%d", &length)

	numbers := make([]int, length)

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

	fmt.Println(do(numbers))
}

package main

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

func thanos(arr[] int64) int {
	length := len(arr)
	possible := 0
	aa := 1
	for i :=0; i < length; i++ {
		if i > 0 {
			if arr[i] >= arr[i-1] {
				aa++
				possible = aa
			} else {
					if aa > possible{
						possible = aa
					}
					aa = 1
			}
		}
	}
	return possible
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _, _ := reader.ReadLine()
	length, err := strconv.ParseInt(string(line[0:]), 10, 0)
	if err != nil {
		fmt.Printf("err %v", err)
	}
	data := make([]int64, length)
	x, _, _ := reader.ReadLine()
	x1 := strings.Split(string(x[0:]), " ")
	for i := 0; i < int(length); i++ {
		data[i], _ = strconv.ParseInt(x1[i], 10, 0)
	}
	n := thanos(data)
	fmt.Printf("%d", n)

}

package main

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

func thanos(arr[] int64) int {
	length := len(arr)
	possible := 1
	aa := 1
	for i :=0; i < length; i++ {
		if i > 0 {
			if arr[i] >= arr[i-1] {
				aa++
				possible = aa
			} else {
					if aa > possible{
						possible = aa
					}
					aa = 1
			}
		}
	}
	return possible
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _, _ := reader.ReadLine()
	length, err := strconv.ParseInt(string(line[0:]), 10, 0)
	if err != nil {
		fmt.Printf("err %v", err)
	}
	data := make([]int64, length)
	x, _, _ := reader.ReadLine()
	x1 := strings.Split(string(x[0:]), " ")
	for i := 0; i < int(length); i++ {
		data[i], _ = strconv.ParseInt(x1[i], 10, 0)
	}
	n := thanos(data)
	fmt.Printf("%d", n)

}

package main

import (
	"fmt"
)

var a [16]int

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0;i < n;i ++ {
		fmt.Scanf("%d", &a[i])
	}
	for i := n;i > 0; i = i >> 1 {
		for j := 0;j < n;j += i {
			inc := true
			for k := j;k < j + i - 1;k ++ {
				if a[k] > a[k + 1] {
					inc = false
				}
			}
			if inc {
				fmt.Printf("%d", i)
				return
			}
		}
	}
}

package main

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

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

func thanosSort(nums []int, i int, j int) int {
	if i >= j {
		return 1
	}

	curMax := 1
	for ; i < j; i++ {
		if nums[i] > nums[i+1] {
			curMax = 0
			break
		}
		curMax++
	}
	mid := i + (j-i)/2
	leftMax := thanosSort(nums, i, mid)
	rightMax := thanosSort(nums, mid+1, j)
	return max(curMax, max(leftMax, rightMax))
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	nums := scanner.Text()
	numsSlice := strings.Split(nums, " ")
	var numbers []int
	for _, v := range numsSlice {
		val, _ := strconv.Atoi(v)
		numbers = append(numbers, val)
	}
	fmt.Println(thanosSort(numbers, 0, size-1))
}

package main

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

func sort(size int, arr []int) int {

	// fmt.Println(arr)
	// fmt.Println(size)
	if size > 2 {
		half := size / 2
		// fmt.Println(arr[:half])
		// fmt.Println(arr[half:])
		left_half := sort(half, arr[:half])
		right_half := sort(half, arr[half:])
		return right_half + left_half

	} else {
		if arr[0] < arr[1] {
			return 2
		} else {
			return 0
		}
	}

}

func main() {
	// fmt.Println("thanos Sort Enter input ")
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimSuffix(text, "\n")
	txt_slice, _ := reader.ReadString('\n')
	txt_slice = strings.TrimSuffix(txt_slice, "\n")
	input_slice := strings.Split(txt_slice, " ")

	size, _ := strconv.Atoi(text)
	inputdata := make([]int, 0)
	for _, v := range input_slice {
		int_v, _ := strconv.Atoi(v)
		inputdata = append(inputdata, int_v)
	}
	fmt.Println(sort(size, inputdata))

}

package main

import (
	"fmt"
)

func sort(size int, arr []int) int {

	if size > 2 {
		half := size / 2
		left_half := sort(half, arr[:half])
		right_half := sort(half, arr[half:])
		if left_half == half && right_half == half && arr[half-1] <= arr[half] {
			return right_half + left_half

		} else if left_half == 1 && right_half == 1 {
			return 1
		} else if left_half < right_half {
			return right_half
		} else if left_half > right_half {
			return left_half
		} else {
			return right_half
		}

	} else {

		if arr[0] < arr[1] {
			return 2
		} else {
			return 1
		}
	}

}

func main() {

	var n int
	fmt.Scanf("%d\n", &n)
	inputdata := make([]int, n)
	for i, _ := range inputdata {
		fmt.Scanf("%d", &inputdata[i])
	}

	if n <= 1 {
		fmt.Println(n)
	} else {
		fmt.Println(sort(n, inputdata))
	}

}

package main

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

func sort(size int, arr []int) int {

	fmt.Println(arr)
	fmt.Println(size)
	if size > 2 {
		half := size / 2
		fmt.Println(arr[:half])
		fmt.Println(arr[half:])
		left_half := sort(half, arr[:half])
		right_half := sort(half, arr[half:])
		return right_half + left_half

	} else {
		if arr[0] < arr[1] {
			return 2
		} else {
			return 0
		}
	}

}

func main() {
	fmt.Println("thanos Sort Enter input ")
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimSuffix(text, "\n")
	txt_slice, _ := reader.ReadString('\n')
	txt_slice = strings.TrimSuffix(txt_slice, "\n")
	input_slice := strings.Split(txt_slice, " ")

	size, _ := strconv.Atoi(text)
	inputdata := make([]int, 0)
	for _, v := range input_slice {
		int_v, _ := strconv.Atoi(v)
		inputdata = append(inputdata, int_v)
	}
	fmt.Println(sort(size, inputdata))

}

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 checkSort(begin int, size int, inputArray []int) int {
	for i:=0; i<size-1;i++ {
		if inputArray[i] > inputArray[i+1] {
			size /= 2
			checkSort(0, size/2, inputArray)
			checkSort( size/2,size, inputArray)
		}
	}
	return size
}

func main() {
	defer writer.Flush()
	var size int

	fmt.Scan(&size)
	inputArray := make([]int, size)
	for i := range inputArray{
		fmt.Scan(&inputArray[i])
	}
	size = checkSort(0,size, inputArray)
	printf("%d", size)
}