package main

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		aa := make([]int, n)
		for i := 0; i < len(aa); i++ {
			aa[i] = reader.NextInt()
		}
		sort.Ints(aa)
		sol(aa)
	}
}

func sol(aa []int) {
	numOdd:=0
	numEven:=0
	for i:=0;i<len(aa);i++{
		if(aa[i]%2==0){
			numEven++
		}else{
			numOdd++
		}
	}
	if(numOdd%2==0 && numEven%2==0){
		writer.Printf("YES \n")
		return
	}else{
		for i:=0;i<len(aa)-1;i++ {
		if(aa[i]+1==aa[i+1]){
			aa[i]=-1
			aa[i+1]=-1
			numEven--
			numOdd--
			if(numOdd%2==0 && numEven%2==0){
				writer.Printf("YES \n")
				return
			}
		}
	}
	writer.Printf("NO \n")
	}
	// fmt.Println(aa)

	// fmt.Println(numEven,numOdd)
	// if(numOdd%2==0 && numEven%2==0){
	// 	writer.Printf("YES \n")
	// }else{
	// 	writer.Printf("NO \n")
	// }

}

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	defer out.Flush()
	for t := ScanInt(); t > 0; t-- {
		solve()
	}

}

func solve() {
	n := ScanInt()
	a := ScanInts(n)
	mevn := make([]int, 0, n)
	modd := make([]int, 0, n)

	for i := 0; i < n; i++ {
		if a[i]%2 == 0 {
			mevn = append(mevn, a[i])
		} else {
			modd = append(modd, a[i])
		}
	}

	if len(mevn)%2 == 0 {
		P("YES")
		return
	}

	for i := 0; i < len(mevn); i++ {
		for j := 0; j < len(modd); j++ {
			if Abs(mevn[i]-modd[j]) == 1 {
				P("YES")
				return
			}
		}
	}
	P("NO")
	return
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"fmt"
	"sort"
)

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

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Scanf("%d\n", &n)
		a := make([]int, n)
		even := 0
		for i := 0; i < n; i++ {
		    fmt.Scanf("%d", &a[i])
		    if a[i] % 2 == 0 {
		        even++
		    }
		}
		fmt.Scanf("\n")
		if even % 2 == 0 {
		    fmt.Println("YES")
		    continue
		}
		flag := false
		sort.Ints(a)
		for i := 0; i < n - 1; i++ {
		    if (a[i] + 1 == a[i + 1]) {
		        flag = true
		        break
		    }
		}
		if flag {
		    fmt.Println("YES")
		} else {
		    fmt.Println("NO")
		}
	}
}

package main

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

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

func main() {
	defer out.Flush()
	inn.Split(bufio.ScanWords)
	for tt := rd(); tt > 0; tt-- {
		n := rd()
		even, odd := []int{}, []int{}
		for i := 0; i < n; i++ {
			x := rd()
			if x%2 == 0 {
				even = append(even, x)
			} else {
				odd = append(odd, x)
			}
		}
		if len(even)%2 == 0 {
			Fprintln(out, "YES")
		} else {
			for _, it := range even {
				for _, j := range odd {
					if it-j == 1 || it-j == -1 {
						Fprintln(out, "YES")
						goto next
					}
				}
			}
			Fprintln(out, "NO")
		}
	next:
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	data := inn.Bytes()
	f := 1
	if data[0] == '-' {
		f = -1
		data = data[1:]
	}
	for _, b := range data {
		x = x*10 + int(b&15)
	}
	return f * x
}
func rdll() (x int64) {
	inn.Scan()
	data := inn.Bytes()
	f := int64(1)
	if data[0] == '-' {
		f = -1
		data = data[1:]
	}
	for _, b := range data {
		x = x*10 + int64(b&15)
	}
	return f * x
}

package main

import (
	"fmt"
	"sort"
)

func main(){
	var T int
	fmt.Scan(&T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Scan(&n)
		A := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&A[i])
		}
		sort.Ints(A)
		var odd, even [] int
		neibours := false
		for i := 0; i < n; i++ {
			if (A[i] & 1) == 1 {
				odd = append(odd, A[i])
			} else {
				even = append(even, A[i])
			}
			if i+1 < n && A[i]+1 == A[i+1] {
				neibours = true
			}
		}
		// fmt.Println(A, neibours)
		if len(odd)%2 == 0 || neibours{
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.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
}

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

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

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

func sol(a []int64) string {
	if len(a)&1 == 1 {
		// should not happen
		return "NO"
	}
	numEven := 0
	numOdd := 0
	for _, ai := range a {
		if ai&1 == 1 {
			numOdd++
		} else {
			numEven++
		}
	}
	if numEven&1 == 0 && numOdd&1 == 0 {
		return "YES"
	}
	sort.Slice(a, func(x, b int) bool {
		return a[x] < a[b]
	})
	for i := 1 ; i < len(a); i++ {
		if a[i] - a[i-1] == 1 {
			return "YES"
		}
	}
	return "NO"
}

package main

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

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)

		res := solve(n, A)

		if res {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

func solve(n int, A []int) bool {
	var cnt int

	for i := 0; i < n; i++ {
		cnt += A[i] & 1
	}

	if cnt&1 == 0 {
		return true
	}

	sort.Ints(A)

	for i := 0; i < n-1; i++ {
		if A[i]+1 == A[i+1] {
			return true
		}
	}
	return false
}

package main

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

func main() {
	s := NewScanner()
	t := s.NextInt()

	for i := 0; i < t; i++ {
		n := s.NextInt()
		arr := make([]int, n)
		m := map[int]int{}
		var c int
		var next bool
		for j := 0; j < n; j++ {
			arr[j] = s.NextInt()
			m[arr[j]]++

			if arr[j]%2 == 0 {
				c++
			}

			if _, ok := m[arr[j]+1]; ok {
				next = true
			}

			if _, ok := m[arr[j]-1]; ok {
				next = true
			}
		}

		if c%2 == 0 || next {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

type scanner struct {
	*bufio.Scanner
}

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

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

// https://codeforces.com/contest/1355/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	even, odd, d := 0, 0, 0
	table := make([]int, 101)
	for i := 0; i < n; i++ {
		var t int
		fmt.Fscan(input, &t)
		table[t]++
		if t%2 == 1 {
			odd++
		} else {
			even++
		}
	}

	for i := 1; i < len(table); i++ {
		d += min(table[i], table[i-1])
	}

	if odd&1 != even&1 {
		fmt.Println("NO")
	} else if odd&1 == 1 && d == 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

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

/*
URL:
https://codeforces.com/contest/1360/problem/C
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	t int
	n int
	A []int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)
		solve(n, A)
	}
}

func solve(n int, A []int) {
	sort.Sort(sort.IntSlice(A))

	odd, even := 0, 0
	for i := 0; i < n; i++ {
		if A[i]%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	if even%2 == 0 && odd%2 == 0 {
		fmt.Println("YES")
		return
	}

	for i := 1; i < n; i++ {
		if AbsInt(A[i]-A[i-1]) == 1 {
			fmt.Println("YES")
			return
		}
	}

	fmt.Println("NO")
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

func solve() {
	t := readInt()
next:
	for i := 0; i < t; i++ {
		n := readInt()
		a := readIntArray(n)
		sort.Ints(a)
		even := make([]int, 0)
		odd := make([]int, 0)
		for i := 0; i < len(a); i++ {
			if a[i]%2 == 0 {
				even = append(even, a[i])
			} else {
				odd = append(odd, a[i])
			}
		}
		if len(even) % 2 == 0 {
			fmt.Println("YES")
		} else {
			for _, v1 := range even {
				for _, v2 := range odd {
					if abs(v1-v2) == 1 {
						fmt.Println("YES")
						continue next
					}
				}
			}
			fmt.Println("NO")
		}
	}
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}
	var t, n int
o:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		odd := 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i]&1 == 1 {
				odd++
			}
		}
		if odd&1 == 0 {
			Fprintln(out, "YES")
			continue
		}
		for i, v := range a {
			for j, w := range a {
				if j == i {
					continue
				}
				if v&1 != w&1 && abs(v-w) == 1 {
					Fprintln(out, "YES")
					continue o
				}
			}
		}
		Fprintln(out, "NO")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}
	var t, n int
o:
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		odd := 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i]&1 == 1 {
				odd++
			}
		}
		if odd&1 == 0 {
			Fprintln(out, "YES")
			continue
		}
		for _, v := range a {
			for _, w := range a {
				if abs(v-w) == 1 {
					Fprintln(out, "YES")
					continue o
				}
			}
		}
		Fprintln(out, "NO")
	}
}

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

package main

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

func main() {
	s := NewScanner()
	t := s.NextInt()

	for i := 0; i < t; i++ {
		n := s.NextInt()
		arr := make([]int, n)
		for j := 0; j < n; j++ {
			arr[j] = s.NextInt()
		}

		sort.Ints(arr)

		var c int
		for j := 0; j < n-1; j++ {
			if arr[j+1]-arr[j] == 1 {
				j++
			} else {
				if arr[j]%2 == 0 {
					c++
				}
				if j == n-2 && arr[j+1]%2 == 0 {
					c++
				}
			}
		}

		if c%2 == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

type scanner struct {
	*bufio.Scanner
}

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

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

package main

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

func main() {
	s := NewScanner()
	t := s.NextInt()

	for i := 0; i < t; i++ {
		n := s.NextInt()
		arr := make([]int, n)
		for j := 0; j < n; j++ {
			arr[j] = s.NextInt()
		}

		sort.Ints(arr)

		ex := []int{}
		for j := 0; j < n-1; j++ {
			if arr[j+1]-arr[j] == 1 {
				j++
			} else {
				ex = append(ex, arr[j])
				if j == n-2 {
					ex = append(ex, arr[j+1])
				}
			}
		}

		c := 0
		for _, e := range ex {
			if e%2 == 0 {
				c++
			}
		}

		if c%2 == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

type scanner struct {
	*bufio.Scanner
}

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

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

package main

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

func main() {
	s := NewScanner()
	t := s.NextInt()

	for i := 0; i < t; i++ {
		n := s.NextInt()
		arr := make([]int, n)
		m := map[int]int{}
		for j := 0; j < n; j++ {
			arr[j] = s.NextInt()
			m[arr[j]]++
		}

		var c int
		for j := 0; j < n; j++ {
			if v, ok := m[arr[j]]; ok && v == 0 {
				continue
			}
			m[arr[j]]--
			if v, ok := m[arr[j]+1]; ok && v > 0 {
				m[arr[j]+1]--
				continue
			}

			if v, ok := m[arr[j]-1]; ok && v > 0 {
				m[arr[j]-1]--
				continue
			}

			if arr[j]%2 == 0 {
				c++
			}
		}

		if c%2 == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

type scanner struct {
	*bufio.Scanner
}

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

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

// https://codeforces.com/contest/1355/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	even, odd := 0, 0
	table := make([]int, 101)
	for i := 0; i < n; i++ {
		var t int
		fmt.Fscan(input, &t)
		table[t]++
	}

	for i := 1; i < len(table); i++ {
		d := min(table[i], table[i - 1])
		table[i] -= d
		table[i - 1] -= d
	}

	for i := 0; i < len(table); i++ {
		if i & 1 == 1 && table[i] > 0 {
			odd += table[i]
		}
		if i & 1 == 0 && table[i] > 0 {
			even += table[i]
		}
	}

	if odd & 1 == 1 || even & 1 == 1 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

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

// https://codeforces.com/contest/1355/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	even, odd, d := 0, 0, 0
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
		if a[i] & 1 == 1 {
			odd++
		} else {
			even++
		}
	}

	sort.Ints(a)
	i := 1
	for i < n {
		if a[i] - a[i - 1] == 1 {
			d++
			i+=2
		} else {
			i++
		}
	}

	odd -= d
	even -= d

	if odd & 1 == 1 || even & 1 == 1 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

// https://codeforces.com/contest/1355/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	even, odd := 0, 0
	for i := 0; i < n; i++ {
		var t int
		fmt.Fscan(input, &t)
		if t % 2 == 0 {
			even++
		} else {
			odd++
		}
	}

	if odd % 2 == 0 && even % 2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

package main

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		aa := make([]int, n)
		for i := 0; i < len(aa); i++ {
			aa[i] = reader.NextInt()
		}
		sort.Ints(aa)
		sol(aa)
	}
}

func sol(aa []int) {
	numOdd:=0
	numEven:=0
	for i:=0;i<len(aa)-1;i++ {
		if(aa[i]+1==aa[i+1]){
			aa[i]=-1
			aa[i+1]=-1
			i++
		}
	}
	// fmt.Println(aa)
	for i:=0;i<len(aa);i++{
		if(aa[i]==-1){
			continue;
		}
		if(aa[i]%2==0){
			numEven++
		}else{
			numOdd++
		}
	}
	// fmt.Println(numEven,numOdd)
	if(numOdd%2==0 && numEven%2==0){
		writer.Printf("YES \n")
	}else{
		writer.Printf("NO \n")
	}

}

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		aa := make([]int, n)
		for i := 0; i < len(aa); i++ {
			aa[i] = reader.NextInt()
		}
		sort.Ints(aa)
		sol(aa)
	}
}

func sol(aa []int) {
	numOdd:=0
	numEven:=0
	for i:=0;i<len(aa)-1;i++ {
		if(aa[i]+1==aa[i+1]){
			aa[i]=-1
			aa[i+1]=-1
		}
	}
	// fmt.Println(aa)
	for i:=0;i<len(aa);i++{
		if(aa[i]==-1){
			continue;
		}
		if(aa[i]%2==0){
			numEven++
		}else{
			numOdd++
		}
	}
	// fmt.Println(numEven,numOdd)
	if(numOdd%2==0 && numEven%2==0){
		writer.Printf("YES \n")
	}else{
		writer.Printf("NO \n")
	}

}

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		aa := make([]int, n)
		for i := 0; i < len(aa); i++ {
			aa[i] = reader.NextInt()
		}
		sort.Ints(aa)
		sol(aa)
	}
}

func sol(aa []int) {
	numOdd:=0
	numEven:=0
	for i:=0;i<len(aa);i++{
		if(aa[i]%2==0){
			numEven++
		}else{
			numOdd++
		}
	}
	for i:=0;i<len(aa)-1;i++ {
		if(aa[i]+1==aa[i+1]){
			aa[i]=-1
			aa[i+1]=-1
			numEven--
			numOdd--
		}
	}
	// fmt.Println(aa)

	// fmt.Println(numEven,numOdd)
	if(numOdd%2==0 && numEven%2==0){
		writer.Printf("YES \n")
	}else{
		writer.Printf("NO \n")
	}

}

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		n := readInt()
		a := readIntArray(n)
		sort.Ints(a)
		for i := 1; i < len(a); i++ {
			if a[i - 1] + 1 == a[i] {
				a[i-1] = -10000
				a[i] = -10000
			}
		}
		revB := make([]int, 2)
		for _, v := range a {
			revB[v % 2]++
		}
		if revB[0] % 2 == 0 && revB[1] % 2 == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		n := readInt()
		a := readIntArray(n)
		sort.Ints(a)
		used := make([]bool, len(a))
		if dfs(a, used, 0) && usedAll(used){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func usedAll(used []bool) bool {
	for _, yes := range used {
		if !yes {
			return false
		}
	}
	return true
}

func dfs(a []int, used []bool, pos int) bool {
	if pos >= len(a) {
		return true
	}
	used[pos] = true
	for i := pos + 1; i < len(a); i++ {
		if !used[i] && (a[pos]%2 == a[i]%2 || (abs(a[pos]-a[i])) <= 1) {
			used[i] = true
			res := dfs(a, used, i + 1)
			if res {
				// fmt.Println("YES", a[pos], a[i])
				return true
			}
			used[i] = false
		}
	}
	used[pos] = false
	return false
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		ans := solve(d)
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

func solve(ang int) int {
	_ans := 180 / gcd(ang, 180)
	ans := _ans
	for ans*ang/180 > ans-2 {
		ans = ans + _ans
	}
	return ans
}

package main

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

var stdin = bufio.NewScanner(os.Stdin)

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

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

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		cur := readInt()
		tmp := gcd(cur, 180)
		if cur == 180-tmp {
			fmt.Println(360 / tmp)
		} else {
			fmt.Println(180 / tmp)
		}
	}
}

package main

import "fmt"

func main() {
	angleMap := map[int]int{}
	for i := 3; i <= 360; i++ {
		unit := float64(180) / float64(i)
		for j := 1; j <= (i - 2); j++ {
			angle := unit * float64(j)
			if angle-float64(int(angle)) > .0 {
				continue
			}
			if angleMap[int(angle)] != 0 {
				continue
			}
			angleMap[int(angle)] = i
		}
	}

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

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ang >= 178{
			fmt.Printf("%d\n",360/g)
		}else{

			var tt int = 180
		//	fmt.Println(g)
			if ang/g +1 == tt/g{
				tt*=2
			}
			for tt/g < 3 {
				tt += 180
			}
			fmt.Printf("%d\n", tt/g)
		}

	}

}

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec 29 00:46:07 2018
//
package main

import "fmt"

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

func main() {
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		n := 180 / gcd(x, 180)
		if (n-2)*180/n < x {
			fmt.Println(n * 2)
		} else {
			fmt.Println(n)
		}
	}
}

package main

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

var stdin = bufio.NewReader(os.Stdin)

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

func readInt() int {
	l, _ := stdin.ReadString('\n')
	i, _ := strconv.Atoi(l)
	return i
}

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		cur := readInt()
		tmp := gcd(cur, 180)
		if cur == 180-tmp {
			fmt.Println(360 / tmp)
		} else {
			fmt.Println(180 / tmp)
		}
	}
}

package main

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

var stdin = bufio.NewReader(os.Stdin)

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

func readInt() int {
	l, _ := stdin.ReadString('\n')
	i, _ := strconv.Atoi(l[:len(l)-1])
	return i
}

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		cur := readInt()
		tmp := gcd(cur, 180)
		if cur == 180-tmp {
			fmt.Println(360 / tmp)
		} else {
			fmt.Println(180 / tmp)
		}
	}
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ans int = -1
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		for j := 1; j <= ang; j++ {
			if ang%j != 0 {
				continue
			}
			if 180%(ang/j) != 0 {
				continue
			}
			n := 180 * j / ang
			if j <= n-2 && n >= 3 {
				ans = n
				break;
			}
			if j > n-2{
				break
			}
		}
		fmt.Printf("%d\n", ans)
	}

}

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ang >= 178{
			fmt.Printf("%d\n",360/g)
		}else{
			var tt int = 180
			for tt/g < 3 {
				tt += 180
			}
			fmt.Printf("%d\n", tt/g)
		}

	}

}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i:=0 ;i < t;i++{
		var ans int = -1
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		for j:=1;j <= ang;j++{
			if ang %j != 0{
				continue
			}
			if 180%(ang/j) != 0 {
				continue
			}
			n := 180*j/ang
			if j <= n-2{
				ans= n
				break;
			}
		}
		fmt.Printf("%d\n",ans)
	}

}

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ang >= 178{
			fmt.Printf("%d\n",360/g)
		}else{

			var tt int = 180
			if g +1 == tt/g{
				tt*=2
			}
			for tt/g < 3 {
				tt += 180
			}
			fmt.Printf("%d\n", tt/g)
		}

	}

}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ans int = -1
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		for j := 1; j <= ang; j++ {
			if ang%j != 0 {
				continue
			}
			if 180%(ang/j) != 0 {
				continue
			}
			n := 180 * j / ang
			if j <= n-2 && n >= 3 {
				ans = n
				break;
			}
		}
		fmt.Printf("%d\n", ans)
	}

}

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	fmt.Println(gcd(1,8))
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ans int = -1
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ans == 179{
			fmt.Printf("360\n",)
		}else{
			fmt.Printf("%d\n",180/g)
		}

	}

}

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ang >= 178{
			fmt.Printf("%d\n",180)
		}else{
			var tt int = 180
			for tt/g < 3 {
				tt += 180
			}
			fmt.Printf("%d\n", tt/g)
		}

	}

}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ans int = -1
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ans == 179{
			fmt.Printf("%d\n",180*179)
		}else{
			fmt.Printf("180\n")
		}

	}

}

package main

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

func gcd(a,b int)int  {
	if b== 0{
		return a
	}
	return gcd(b,a%b)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscanf(buf, "%d\n", &t)
	for i := 0; i < t; i++ {
		var ang int
		fmt.Fscanf(buf, "%d\n", &ang)
		g := gcd(ang,180)
		if ang == 180{
			fmt.Printf("-1\n")
		}else if ang >= 178{
			fmt.Printf("%d\n",360/g)
		}else{
			fmt.Printf("%d\n",180/g)
		}

	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		find := false
		for i := 3; i <= 180; i++ {
			small := float64(180) / float64(i)
			if small*float64(i-2)+1e-9 < float64(d) {
				continue
			}
			div := int(float64(d) / small)
			if math.Abs(small*float64(div)-float64(d)) < 1e-9 {
				fmt.Fprintf(out, "%d\n", i)
				find = true
				break
			}
		}
		if !find {
			fmt.Fprintf(out, "%d\n", -1)
		}
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		find := false
		for i := 3; i <= 180; i++ {
			small := float64(180) / float64(i)
			if small*float64(i-2)+1e-10 < float64(d) {
				continue
			}
			div := int(float64(d) / small)
			if math.Abs(small*float64(div)-float64(d)) < 1e-10 || math.Abs(small*float64(div+1)-float64(d)) < 1e-10 {
				fmt.Fprintf(out, "%d\n", i)
				find = true
				break
			}

		}
		if !find {
			fmt.Fprintf(out, "-1\n")
		}
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		find := false
		for i := 3; i <= 180; i++ {
			small := float64(180) / float64(i)
			if small*float64(i-2)+1e-9 < float64(d) {
				continue
			}
			div := int(float64(d) / small)
			if math.Abs(small*float64(div)-float64(d)) < 1e-9 {
				fmt.Fprintf(out, "%d\n", i)
				find = true
				break
			}

		}
		if !find {
			fmt.Fprintf(out, "−1\n")
		}
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		find := false
		for i := 3; i <= 180; i++ {
			small := float64(180) / float64(i)
			if small*float64(i-2)+1e-9 < float64(d) {
				continue
			}
			div := int(float64(d) / small)
			if math.Abs(small*float64(div)-float64(d)) < 1e-9 {
				fmt.Fprintf(out, "%d\n", i)
				find = true
				break
			}

		}
		if !find {
			fmt.Fprintf(out, "?1\n")
		}
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, d := 0, 0
	fmt.Fscanf(in, "%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d\n", &d)
		for i := 3; i <= 180; i++ {
			small := float64(180) / float64(i)
			if small*float64(i-2)+1e-9 < float64(d) {
				continue
			}
			div := int(float64(d) / small)
			if math.Abs(small*float64(div)-float64(d)) < 1e-9 {
				fmt.Fprintf(out, "%d\n", i)
				break
			}
		}
	}
	return
}


package main

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

func main() {

	n := readN()
	a := readA(n)

	// sorted key set of m
	mref := make([]int, 0)
	m := make(map[int]int, n);

	for i := 0; i<n; i++ {
		v := a[i]
		_, ok := m[v];
		if ok {
			m[v] = m[v] + 1
		} else {
			m[v] = 1
		}
		mref = insert(mref, v)
	}

	//fmt.Println(m)
	//fmt.Println(mref)

	sum := 0
	pos := -1
	for i,v := range mref {
		sum += m[v]
		if sum >= 3 {
			pos = i
			break
		}
	}

	var ans int64

	if pos == 0 {
		ans = nck(m[mref[0]], 3)
	} else if pos == 1 {
		ans = nck(m[mref[1]], 3 - m[mref[0]])
	} else if pos == 2 {
		ans = int64(m[mref[2]])
	} else {
		panic("cannot reach here; pos = " + fmt.Sprintf("%v", pos))
	}

	fmt.Println(ans)

}

func insert(arr []int, v int) []int {
	if len(arr) == 3 && v > arr[2] {
		return arr
	}

	pos := -1
	for i,ele := range arr {
		if ele >= v {
			pos = i
			break
		}
	}
	var res []int
	if pos == -1 {
		// append at the end
		res = make([]int, len(arr) + 1)
		copy(res, arr)
		res[len(arr)] = v
	} else {
		if arr[pos] == v {
			return arr
		}
		res = make([]int, 0)
		res = append(res, arr[0:pos]...)
		res = append(res, v)
		if len(res) < 3 {
			//fmt.Println(res)
			//fmt.Println(arr)
			//fmt.Println(pos)
			res = append(res, arr[pos:]...)
		}
		if len(res) > 3 {
			tmp := make([]int, 3)
			copy(tmp, res)
			res = tmp
		}

	}

	return res
}

func nck(n,k int) int64 {
	if n-k < k {
		k = n-k
	}

	var k_fact int64
	k_fact = 1
	for i := int64(1); i<=int64(k); i++ {
		k_fact = k_fact * i
	}

	var n_minus_k_fact int64
	n_minus_k_fact = 1
	for i := int64(n-k+1); i<=int64(n); i++ {
		n_minus_k_fact *= i
	}
	return n_minus_k_fact / k_fact
}

func readN() int {
	var a int
	fmt.Scan(&a)
	//a = 100000

	return a
}

func readA(n int) []int {
	a := make([]int, n)

	reader := bufio.NewReader(os.Stdin)

	//fmt.Scan(a)

	for i := 0; i<n; i++ {
		fmt.Fscan(reader, &a[i])
		//a[i] = 1000000000
	}

	return a
}

//http://codeforces.com/problemset/problem/817/B
package main

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

func main() {

	reader := NewStdReader(os.Stdin)
	n := reader.ReadInt()

	if n == 3 {
		fmt.Print(1)
		return
	}

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}
	sort.Ints(a)
	if a[3] != a[2] {
		fmt.Print(1)
		return
	}

	c := 1
	for i := 3; i < n; i++ {
		if a[i] == a[2] {
			c++
		} else {
			break
		}
	}
	if a[2] != a[1] {
		fmt.Print(c)
		return
	}

	if a[1] != a[0] {
		d := c + 1
		fmt.Print(Combination(d, 2))
		return
	}

	e := c + 2
	fmt.Print(Combination(e, 3))

}

// Combination computes n choose k
// equal to (n!)/((n-k)! k!)
// Panics on integer overflow
// Returns 0 if either n or k are negative
func Combination(n, k int) int64 {
	if n < 0 || k < 0 || k > n {
		return 0
	}
	if n == 0 && k == 0 {
		return 1
	}

	// Make k the greater of the two
	if k < n-k {
		k = n - k
	}
	// Compute (n!)/(k)!, checking for overflow
	prev := int64(1)
	mul := int64(1)
	for i := k + 1; i <= n; i++ {
		prev = mul
		mul *= int64(i)
		if mul < prev {
			panic("math: integer overflow")
		}
	}
	// Divide by (n-k)!
	for i := 2; i <= n-k; i++ {
		mul = mul / int64(i)
	}
	return mul
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

//http://codeforces.com/problemset/problem/817/B
package main

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

func main() {
	fmt.Print(Combination(1000, 3))

	reader := NewStdReader(os.Stdin)
	n := reader.ReadInt()

	if n == 3 {
		fmt.Print(1)
		return
	}

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}
	sort.Ints(a)
	if a[3] != a[2] {
		fmt.Print(1)
		return
	}

	c := 1
	for i := 3; i < n; i++ {
		if a[i] == a[2] {
			c++
		} else {
			break
		}
	}
	if a[2] != a[1] {
		fmt.Print(c)
		return
	}

	if a[1] != a[0] {
		d := c + 1
		fmt.Print((d+1)*(d/2) + (d+1)/2*(d%2))
		return
	}

	e := c + 2
	fmt.Print(Combination(e, 3))

}

func Combination(n, k int) int {
	c := 0
	for i := 1; i <= n-2; i++ {
		for j := i + 1; j <= n-1; j++ {
			for k := j + 1; k <= n; k++ {
				c++
			}
		}
	}

	return c
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

import (
	"fmt"
)

func main() {

	n := readN()
	a := readA(n)

	// sorted key set of m
	mref := make([]int, 0)
	m := make(map[int]int, n);

	for i := 0; i<n; i++ {
		v := a[i]
		_, ok := m[v];
		if ok {
			m[v] = m[v] + 1
		} else {
			m[v] = 1
		}
		mref = insert(mref, v)
	}

	//fmt.Println(m)
	//fmt.Println(mref)

	sum := 0
	pos := -1
	for i,v := range mref {
		sum += m[v]
		if sum >= 3 {
			pos = i
			break
		}
	}

	var ans int64

	if pos == 0 {
		ans = nck(m[mref[0]], 3)
	} else if pos == 1 {
		ans = nck(m[mref[1]], 3 - m[mref[0]])
	} else if pos == 2 {
		ans = int64(m[mref[2]])
	} else {
		panic("cannot reach here; pos = " + fmt.Sprintf("%v", pos))
	}

	fmt.Println(ans)

}

func insert(arr []int, v int) []int {
	pos := -1
	for i,ele := range arr {
		if ele >= v {
			pos = i
			break
		}
	}
	var res []int
	if pos == -1 {
		// append at the end
		res = make([]int, len(arr) + 1)
		copy(res, arr)
		res[len(arr)] = v
	} else {
		if arr[pos] == v {
			return arr
		}
		res = make([]int, 0)
		res = append(res, arr[0:pos]...)
		res = append(res, v)
		res = append(res, arr[pos:]...)
	}

	return res
}

func nck(n,k int) int64 {
	if n-k < k {
		k = n-k
	}

	var k_fact int64
	k_fact = 1
	for i := int64(1); i<=int64(k); i++ {
		k_fact = k_fact * i
	}

	var n_minus_k_fact int64
	n_minus_k_fact = 1
	for i := int64(n-k+1); i<=int64(n); i++ {
		n_minus_k_fact *= i
	}
	return n_minus_k_fact / k_fact
}

func readN() int {
	var a int
	fmt.Scan(&a)
	//a = 100000

	return a
}

func readA(n int) []int {
	a := make([]int, n)

	fmt.Scanln(a)

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

	return a
}

package main

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

func main() {

	n := readN()
	a := readA(n)

	// sorted key set of m
	mref := make([]int, 0)
	m := make(map[int]int, n);

	for i := 0; i<n; i++ {
		v := a[i]
		_, ok := m[v];
		if ok {
			m[v] = m[v] + 1
		} else {
			m[v] = 1
		}
		mref = insert(mref, v)
	}

	fmt.Println(m)
	fmt.Println(mref)

	sum := 0
	pos := -1
	for i,v := range mref {
		sum += m[v]
		if sum >= 3 {
			pos = i
			break
		}
	}

	var ans int64

	if pos == 0 {
		ans = nck(m[mref[0]], 3)
	} else if pos == 1 {
		ans = nck(m[mref[1]], 3 - m[mref[0]])
	} else if pos == 2 {
		ans = int64(m[mref[2]])
	} else {
		panic("cannot reach here; pos = " + fmt.Sprintf("%v", pos))
	}

	fmt.Println(ans)

}

func insert(arr []int, v int) []int {
	pos := -1
	for i,ele := range arr {
		if ele >= v {
			pos = i
			break
		}
	}
	var res []int
	if pos == -1 {
		// append at the end
		res = make([]int, len(arr) + 1)
		copy(res, arr)
		res[len(arr)] = v
	} else {
		if arr[pos] == v {
			return arr
		}
		res = make([]int, 0)
		res = append(res, arr[0:pos]...)
		res = append(res, v)
		res = append(res, arr[pos:]...)
	}

	return res
}

func nck(n,k int) int64 {
	if n-k < k {
		k = n-k
	}

	var k_fact int64
	k_fact = 1
	for i := int64(1); i<=int64(k); i++ {
		k_fact = k_fact * i
	}

	var n_minus_k_fact int64
	n_minus_k_fact = 1
	for i := int64(n-k+1); i<=int64(n); i++ {
		n_minus_k_fact *= i
	}
	return n_minus_k_fact / k_fact
}

func readN() int {
	var a int
	fmt.Scan(&a)
	//a = 100000

	return a
}

func readA(n int) []int {
	a := make([]int, n)

	reader := bufio.NewReader(os.Stdin)

	//fmt.Scan(a)

	for i := 0; i<n; i++ {
		fmt.Fscan(reader, &a[i])
		//a[i] = 1000000000
	}

	return a
}

package main

import (
	"fmt"
)

func main() {

	var n int

	fmt.Scan(&n)

	a := make([]int, n);

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

	m := make(map[int]int, n);
	// sorted key set of m
	mref := make([]int, 0)

	for _,v := range a {
		_, ok := m[v];
		if ok {
			m[v] = m[v] + 1
		} else {
			m[v] = 1
		}
		mref = insert(mref, v)
	}

	//fmt.Println(m)
	//fmt.Println(mref)

	sum := 0
	pos := -1
	for i,v := range mref {
		sum += m[v]
		if sum >= 3 {
			pos = i
			break
		}
	}

	ans := -1

	if pos == 0 {
		ans = nck(m[mref[0]], 3)
	} else if pos == 1 {
		ans = nck(m[mref[1]], 3 - m[mref[0]])
	} else if pos == 2 {
		ans = m[mref[2]]
	} else {
		panic("cannot reach here; pos = " + fmt.Sprintf("%v", pos))
	}

	fmt.Println(ans)

}

func insert(arr []int, v int) []int {
	pos := -1
	for i,ele := range arr {
		if ele >= v {
			pos = i
			break
		}
	}
	var res []int
	if pos == -1 {
		// append at the end
		res = make([]int, len(arr) + 1)
		copy(res, arr)
		res[len(arr)] = v
	} else {
		if arr[pos] == v {
			return arr
		}
		res = make([]int, 0)
		res = append(res, arr[0:pos]...)
		res = append(res, v)
		res = append(res, arr[pos:]...)
	}

	return res
}

func nck(n,k int) int {
	k_fact := 1
	for i := 1; i<=k; i++ {
		k_fact *= i
	}
	n_minus_k_fact := 1
	for i := n-k+1; i<=n; i++ {
		n_minus_k_fact *= i
	}
	return n_minus_k_fact / k_fact
}

//http://codeforces.com/problemset/problem/817/B
package main

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

func main() {

	reader := NewStdReader(os.Stdin)
	n := reader.ReadInt()

	if n == 3 {
		fmt.Print(1)
		return
	}

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
	}
	sort.Ints(a)
	if a[3] != a[2] {
		fmt.Print(1)
		return
	}

	c := 1
	for i := 3; i < n; i++ {
		if a[i] == a[2] {
			c++
		} else {
			break
		}
	}
	if a[2] != a[1] {
		fmt.Print(c)
		return
	}

	if a[1] != a[0] {
		d := c + 1
		fmt.Print((d+1)*(d/2) + (d+1)/2*(d%2))
		return
	}

	e := c + 2
	fmt.Print(Combination(e, 3))

}

// Combination computes n choose k
// equal to (n!)/((n-k)! k!)
// Panics on integer overflow
// Returns 0 if either n or k are negative
func Combination(n, k int) int64 {
	if n < 0 || k < 0 || k > n {
		return 0
	}
	if n == 0 && k == 0 {
		return 1
	}

	// Make k the greater of the two
	if k < n-k {
		k = n - k
	}
	// Compute (n!)/(k)!, checking for overflow
	prev := int64(1)
	mul := int64(1)
	for i := k + 1; i <= n; i++ {
		prev = mul
		mul *= int64(i)
		if mul < prev {
			panic("math: integer overflow")
		}
	}
	// Divide by (n-k)!
	for i := 2; i <= n-k; i++ {
		mul = mul / int64(i)
	}
	return mul
}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}


package main

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

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}

func main() {
	var arrS []string
	var s, tmp string
	var t, count, min int
	min = 1000000000
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%s\n", &s)
		arrS = append(arrS, s)
	}
	tmp = sortString(arrS[0])
	for i := 1; i < t; i++ {
		if tmp != sortString(arrS[i]) {
			fmt.Println("-1")
			os.Exit(0)
		}
	}
	for i := 0; i < t; i++ {
		for j := 0; j < t; j++ {
			if j == i {
				continue
			}
			tmp = arrS[j]
			for tmp != arrS[i] {
				tmp = tmp[1:] + tmp[:1]
				count++
				if count > 2501 {
					fmt.Println("-1")
					os.Exit(0)
				}
			}
		}
		if min > count {
			min = count
		}
		count = 0
	}
	fmt.Println(min)
}

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	ss := make([]string, n)
	for i := range ss {
		I(&ss[i])
	}
	var res int64 = 1e13
	for o := 0; o < n; o++ {
		var ans int64
		for i := 0; i < n; i++ {
			for j := 0; j < len(ss[0]); j++ {
				if shift(ss[i], j) == ss[o] {
					ans += int64(j)
					break
				} else if j == len(ss[0])-1 {
					O("-1\n")
					return
				}
			}
		}
		if res > ans {
			res = ans
		}
	}
	O(res, "\n")
}

func shift(s string, num int) string {
	return s[num:] + s[:num]
}

package main

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

func solve() {
	n := readInt()
	a := make([][]byte, n)
	for i := 0; i < n; i++ {
		a[i] = []byte(readString())
	}
	ans := 1000000
	for i := 0; i < len(a[0]); i++ {
		b := rot(a[0], i)
		total := i
		cnt := 1
	outer:
		for j := 1; j < n; j++ {
			for k := 0; k < len(a[0]); k++ {
				c := rot(a[j], k)
				ok := true
				for l := 0; l < len(c); l++ {
					if c[l] != b[l] {
						ok = false
						break
					}
				}
				if ok {
					cnt++
					total += k
					continue outer
				}
			}
		}
		if cnt == n {
			ans = min(total, ans)
		} else {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(ans)
}

func rot(buf []byte, i int) []byte {
	b := make([]byte, 0)
	b = append(b, buf[i:]...)
	b = append(b, buf[:i]...)
	return b
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	n := readInt()
	a := make([][]byte, n)
	for i := 0; i < n; i++ {
		a[i] = []byte(readString())
	}
	ans := 1000000
outer:
	for i := 0; i < len(a[0]); i++ {
		b := rot(a[0], i)
		total := i
	inner:
		for j := 1; j < n; j++ {
			matched := false
		shift:
			for k := 0; k < len(a[0]); k++ {
				c := rot(a[j], k)
				for l := 0; l < len(c); l++ {
					if c[l] != b[l] {
						continue shift
					}
				}
				total += k
				matched = true
				continue inner
			}
			if !matched {
				continue outer
			}
		}
		ans = min(total, ans)
	}
	if ans == 1000000 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

func rot(buf []byte, i int) []byte {
	b := make([]byte, 0)
	b = append(b, buf[i:]...)
	b = append(b, buf[:i]...)
	return b
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	n := readInt()
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = readString()
	}
	ans := 1000000
outer:
	for i := 0; i < len(a[0]); i++ {
		b := a[0][i:] + a[0][:i]
		total := i
	inner:
		for j := 1; j < n; j++ {
			matched := false
			for k := 0; k < len(a[0]); k++ {
				c := a[j][k:] + a[j][:k]
				if c == b {
					total += k
					matched = true
					continue inner
				}
			}
			if !matched {
				continue outer
			}
		}
		ans = min(total, ans)
	}
	if ans == 1000000 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func Solve(io *FastIO) {
	N := io.NextInt()

	S := make([]string, N)
	T := make([]string, N)
	for i := 0; i < N; i++ {
		S[i] = io.NextLine()
		T[i] = S[i] + S[i]
	}
	M := len(S[0])

	best := math.MaxInt32
	for i := 0; i < M; i++ {
		k := i + M
		find := T[0][i:k]
		moves := 0
		for j := 0; j < N; j++ {
			idx := strings.Index(T[j], find)
			if idx < 0 {
				moves = math.MaxInt32
				break
			}
			moves += idx
		}
		best = Min(best, moves)
	}

	if best < math.MaxInt32 {
		io.Printf("%d\n", best)
	} else {
		io.Printf("-1\n");
	}
}

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

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}

package main

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

func solve() {
	n := readInt()
	a := make([][]byte, n)
	for i := 0; i < n; i++ {
		a[i] = []byte(readString())
	}
	ans := 100000
	for i := 0; i < n; i++ {
		total := 0
		for j := 0; j < n; j++ {
			c := cost(a[i], a[j])
			if c == -1 {
				fmt.Println(-1)
				return
			}
			total += c
		}
		ans = min(total, ans)
	}
	fmt.Println(ans)
}

func cost(a, b []byte) int {
	c := make([]byte, len(b))
	copy(c, b)
	res := 0
	// fmt.Println(string(a), string(c))
	for i := 0; i < len(a); i++ {
		// fmt.Println(i, string(a), string(c))
		if a[i] == c[0] {
			c = c[1:]
		} else {
			ok := false
			// fmt.Println(string(c))
			for j := 0; j < len(c); j++ {
				if a[i] != c[0] {
					v := c[0]
					c = c[1:]
					c = append(c, v)
					res++
				} else {
					c = c[1:]
					ok = true
					break
				}
			}
			if !ok {
				return -1
			}
		}
	}
	return res
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	a := []byte(readString())
	cnt := 0
	for ii := 0; ii < len(a)/2; ii++ {
		if a[ii] != a[len(a)-ii-1] {
			cnt++
		}
	}
	if len(a)%2 == 1 && cnt <= 1 {
		fmt.Println("YES")
		return
	}
	if cnt != 1 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

var scanner *bufio.Scanner

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

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

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

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

// IO

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

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

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

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

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

package main

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

func sortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}

func main() {
	var arrS []string
	var s, tmp string
	var t, count, min int
	min = 1000000000
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%s\n", &s)
		arrS = append(arrS, s)
	}
	tmp = sortString(arrS[0])
	for i := 1; i < t; i++ {
		if tmp != sortString(arrS[i]) {
			fmt.Println("-1")
			os.Exit(0)
		}
	}
	for i := 0; i < t; i++ {
		for j := 0; j < t; j++ {
			if j == i {
				continue
			}
			tmp = arrS[j]
			for tmp != arrS[i] {
				tmp = tmp[1:] + tmp[:1]
				count++
				if count > 50 {
					fmt.Println("-1")
					os.Exit(0)
				}
			}
		}
		if min > count {
			min = count
		}
		count = 0
	}
	fmt.Println(min)
}