package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for idx := 0; idx < t; idx++ {
		fmt.Println(Calculation())
	}
}

func Calculation() string {
	var cnt int
	Scan(&cnt)
	data := make([]int, cnt)
	for idx := 0; idx < cnt; idx++ {
		Scan(&data[idx])
	}
	if cnt == 1 && data[0] == 1 {
		return "YES"
	}
	if cnt == 1 {
		return "NO"
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i] > data[j]
	})
	if data[0]-data[1] > 1 {
		return "NO"
	}
	return "YES"
}

func Scan(a interface{}) {
	fmt.Fscan(in, a)
}

package main

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

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, typeNum, element int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &typeNum)
		max1, max2 := 0, 0
		for i := 0; i < typeNum; i++ {
			fmt.Fscan(in, &element)
			if max1 < element {
				max1, max2 = element, max1
			} else if max2 < element {
				max2 = element
			}
		}
		if max1-max2 >= 2 {
			fmt.Fprintln(out, "no")
		} else {
			fmt.Fprintln(out, "yes")
		}
	}
}

package main

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

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, typeNum, element int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &typeNum)
		arr := make([]int, typeNum)
		for i := 0; i < typeNum; i++ {
			fmt.Fscan(in, &element)
			arr[i] = element
		}
		if process(arr) {
			fmt.Fprintln(out, "yes")
		} else {
			fmt.Fprintln(out, "no")
		}
	}
}

func process(arr []int) bool {
	if len(arr) == 0 {
		return true
	} else if len(arr) == 1 {
		if arr[0] <= 1 {
			return true
		} else {
			return false
		}
	}
	sort.Ints(arr)
	return arr[len(arr)-1]-arr[len(arr)-2] <= 1
}

package main

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

var in = bufio.NewReader(os.Stdin)

func solve(){
	var n int
	fmt.Fscan(in, &n)
    v:=make([]int,n)

	for i:=0;i<n;i++{
		fmt.Fscan(in, &v[i])
	}

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

	// fmt.Println(v)
	if n==1{
		if v[0]<2{
			fmt.Println("YES")
		} else{
			fmt.Println("NO")
		}
		return
	}

	if v[0]<=v[1]+1{
		fmt.Println("YES")
	} else{
		fmt.Println("NO")
	}
}
func main() {
	var tc int
    fmt.Scan(&tc)
	// fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func solve(){
	var n int
	fmt.Fscan(in, &n)
    v:=make([]int,n)

	for i:=0;i<n;i++{
		fmt.Fscan(in, &v[i])
	}

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

	// fmt.Println(v)
	if n==1{
		if v[0]<2{
			fmt.Println("YES")
		} else{
			fmt.Println("NO")
		}
		return
	}

	if v[0]<=v[1]+1{
		fmt.Println("YES")
	} else{
		fmt.Println("NO")
	}
}
func main() {
	var tc int
    fmt.Fscan(in,&tc)
	// fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

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

type CF1660B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1660B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1660B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1660B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1660B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1660B
Date: 3/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/B
Problem: CF1660B
**/
func (in *CF1660B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		sum := int64(0)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			sum += int64(arr[i])
		}

		ans := false
		if n == 1 {
			if sum == 1 {
				ans = true
			}
		} else {
			sort.Ints(arr)
			ws := true
			if arr[n-1]-arr[n-2] > 1 {
				ws = false
			}

			ans = ws
		}

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

func NewCF1660B(r *bufio.Reader) *CF1660B {
	return &CF1660B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1660B(bufio.NewReader(os.Stdin)).Run()
}

package main

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

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i > 0; i-- {
		n := read()
		max1, max2 := 0, 0
		for i := 1; i <= n; i++ {
			if tmp := read(); max1 <= tmp {
				max1, max2 = tmp, max1
			} else if tmp > max2 {
				max2 = tmp
			}
		}
		if max1-max2 >= 2 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}
}

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

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if n == 1 {
			var x int
			fmt.Fscan(in,&x)
			if x > 1 {
				fmt.Fprintln(out,"NO")
				continue
			} else {
				fmt.Fprintln(out,"YES")
				continue
			}
		}
		largest:=0
		second_largest:=0
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x >= largest {
				second_largest= largest
				largest = x
			} else if x > second_largest  {
				second_largest= x
			}
		}
		if largest - second_largest > 1 {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out,"YES")
		}
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(in, &a[i])
		}
		sort.Ints(a)
		if n == 1 && a[0] == 1 || n > 1 && a[n-1] <= a[n-2]+1 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

const (
	MaxInt32 = 1 << 31 - 1
)

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for t > 0 {
		var n int
		fmt.Fscan(cin, &n)
		candies := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &candies[i])
		}
		sort.Slice(candies, func(i, j int) bool {
			return candies[i] < candies[j]
		})
		if n == 1 {
			if candies[0] > 1 {
				fmt.Println("NO")
			}else {
				fmt.Println("YES")
			}
		}else if candies[n-1] - candies[n-2] > 1 {
			fmt.Println("NO")
		}else {
			fmt.Println("YES")
		}

		 t -= 1
	}
}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"sort"
)

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

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

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	t   = 0
	a []int
	res []int
	s   *list.List
	cur = 0
)

func solve() {
	scan(&t)
	for t != 0 {
		t--
		scan(&n)
		if n == 1 {
			x := 0
			scan(&x)
			if x >= 2 {
				printf("no\n")
			}else {
				printf("yes\n")
			}
			continue
		}
		ar := make([]int, n)

		sum := 0
		for i:=0;i<n;i++{
			scan(&ar[i])
			sum += ar[i]
		}
		sort.Slice(ar, func(i, j int) bool {
			return ar[i] > ar[j]
		})

		if ar[0]-ar[1] >= 2 {
			printf("no\n")
		}else {
			printf("yes\n")
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		if a[n]-a[n-1] > 1 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}
}

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

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	arr := make([]int,n)
	for i := 0;i < n;i++{
		fmt.Fscan(in,&arr[i])
	}
	sort.Slice(arr, func(i, j int) bool {
		return arr[i] < arr[j]
	})
	if n == 1{
		if arr[0] != 1{
			fmt.Fprintln(out,"No")
		}else{
			fmt.Fprintln(out,"Yes")
		}
		return
	}
	b := arr[n - 1] - arr[n - 2] <= 1
	if b{
		fmt.Fprintln(out,"Yes")
	}else{
		fmt.Fprintln(out,"No")
	}
}

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

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

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

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()
  var t int
  for scanf("%d\n", &t) ; t > 0 ; t-- {
    var n int
    scanf("%d\n", &n)
    a := make([]int, n)
    for i := 0 ; i < n ; i++ {
      var v int
      scanf("%d", &v)
      a[i] = v
    }
    scanf("\n")
    sort.SliceStable(a, func(i, j int) bool { return a[i] > a[j]})
    if (n == 1 && a[0] > 1) || (n >= 2 && a[0] > a[1] + 1) {
      printf("NO\n")
    } else {
      printf("YES\n")
    }
  }
}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t int

	Fscan(in, &t)

	for k := 0; k < t; k++ {
		var n int

		max := int64(0)
		second := int64(0)

		Fscan(in, &n)

		for i := 0; i < n; i++ {
			var x int64
			Fscan(in, &x)

			if x > second {
				second = x
			}

			if second > max {
				max, second = second, max
			}
		}
		if max > second+1 {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}

}

package main

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

/*
5
4
3 3 5 5
3
1 2 4
4
1 1 3 4
5
1 4 5 6 7
3
1 7 8
---
YES
NO
YES
YES
YES
======

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	scanf("%d\n", &n)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	sort.Ints(a)

	if n == 1 && a[0] > 1 || n > 1 && a[n-1]-a[n-2] > 1 {
		fmt.Fprintln(writer, "NO")
	} else {
		fmt.Fprintln(writer, "YES")
	}
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for t := t; t > 0; t-- {
		var n int
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int, n)
		mx := 0
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			if a[i] > mx {
				mx = a[i]
			}
		}
		fmt.Fscanf(in, "\n")
		cnt := 0
		mx1 := 0
		for i := 0; i < n; i++ {
			if a[i] != mx {
				if a[i] > mx1 {
					mx1 = a[i]
				}
			} else {
				cnt++
			}
		}
		if (cnt == 1 && mx-mx1 > 1) || (n < 2 && mx > 1) {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}

	}
}

package main

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

func main() {
	in,out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t:=0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		nums:= make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
		}
		sort.Ints(nums)
		if len(nums)==1{
			if nums[0] >1{
				fmt.Fprintln(out, "NO")
			}else {
				fmt.Fprintln(out, "YES")
			}
		}else {
			if nums[len(nums)-1]-nums[len(nums)-2]>1{
				fmt.Fprintln(out, "NO")
			}else {
				fmt.Fprintln(out, "YES")
			}

		}
	}
}

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
}

package main

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

func solve(cin *scanner, cout *writer, cerr *writer) {
	n := cin.NextInt()
	a := cin.NextInts(n)
	if n == 1 {
		if a[0] >= 2 {
			cout.Println("NO")
		} else {
			cout.Println("yEs")
		}
		return
	}
	sort.Ints(a)
	if a[n-2] == a[n-1] || a[n-2]+1 == a[n-1] {
		cout.Println("YeS")
	} else {
		cout.Println("nO")
	}
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

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

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker

package main

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

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

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

		var a, b int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			if v > a {
				a, b = v, a
			} else if v > b {
				b = v
			}
		}

		if a-b <= 1 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	Scan(&t)
	for idx := 0; idx < t; idx++ {
		fmt.Println(Calculation())
	}
}

func Calculation() string {
	var cnt int
	Scan(&cnt)
	data := make([]int, cnt)
	for idx := 0; idx < cnt; idx++ {
		Scan(&data[idx])
	}
	if cnt == 1 && data[0] == 1 {
		return "YES"
	}
	if cnt == 1 {
		return "NO"
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i] > data[j]
	})
	if data[0]-data[1] > 1 {
		return "NO"
	}
	return "YES"
}

func Scan(a interface{}) {
	fmt.Fscan(in, a)
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for idx := 0; idx < t; idx++ {
		fmt.Println(Calculation())
	}
}

func Calculation() string {
	var cnt int
	fmt.Fscan(in, &cnt)
	data := make([]int, cnt)
	for idx := 0; idx < cnt; idx++ {
		fmt.Fscan(in, &data[idx])
	}
	if cnt == 1 && data[0] == 1 {
		return "YES"
	}
	if cnt == 1 {
		return "NO"
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i] > data[j]
	})
	if data[0] - data[1] > 1 {
		return "NO"
	}
	return "YES"
}

package main

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

func main() {
	var t int
	Scan(&t)
	for idx := 0; idx < t; idx++ {
		fmt.Println(Calculation())
	}
}

func Calculation() string {
	var cnt int
	Scan(&cnt)
	data := make([]int, cnt)
	for idx := 0; idx < cnt; idx++ {
		Scan(&data[idx])
	}
	if cnt == 1 && data[0] == 1 {
		return "YES"
	}
	if cnt == 1 {
		return "NO"
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i] > data[j]
	})
	if data[0]-data[1] > 1 {
		return "NO"
	}
	return "YES"
}

func Scan(a interface{}) {
	fmt.Fscan(bufio.NewReader(os.Stdin), &a)
}

func Scanln(a interface{}) {
	fmt.Fscanln(bufio.NewReader(os.Stdin), &a)
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for idx := 0; idx < t; idx++ {
		fmt.Println(Calculation())
	}
}

func Calculation() string {
	var cnt int
	fmt.Fscan(in, &cnt)
	data := make([]int, cnt)
	for idx := 0; idx < cnt; idx++ {
		fmt.Fscan(in, &data[idx])
	}
	if cnt == 1 && data[0] != 1 {
		return "NO"
	}
	sort.Slice(data, func(i, j int) bool {
		return data[i] > data[j]
	})
	currCnt := data[0]
	for idx := 0; idx < cnt; idx++ {
		if currCnt == data[idx] {
			continue
		}
		if currCnt == data[idx]+1 {
			if idx+1 == cnt {
				return "YES"
			}
			currCnt = data[idx+1]
			continue
		}
		return "NO"
	}
	return "YES"
}

package main

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

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, typeNum, element int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &typeNum)
		arr := make([]int, typeNum)
		for i := 0; i < typeNum; i++ {
			fmt.Fscan(in, &element)
			arr[i] = element
		}
		if process(arr) {
			fmt.Fprintln(out, "yes")
		} else {
			fmt.Fprintln(out, "no")
		}
	}
}

func process(arr []int) bool {
	if len(arr) == 0 {
		return false
	} else if len(arr) == 1 {
		if arr[0] <= 1 {
			return true
		} else {
			return false
		}
	}
	var a, b int
	if arr[0] > arr[1] {
		a, b = arr[0], arr[1]
	} else {
		a, b = arr[1], arr[0]
	}
	for i:=2;i<len(arr);i++{
		if arr[i]>a{
			a = arr[i]
		} else if arr[i]>b{
			b = arr[i]
		}
	}
	return a-b <= 1
}

package main

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

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, typeNum, element int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &typeNum)
		arr := make([]int, typeNum)
		for i := 0; i < typeNum; i++ {
			fmt.Fscan(in, &element)
			arr[i] = element
		}
		if process(arr) {
			fmt.Fprintln(out, "yes")
		} else {
			fmt.Fprintln(out, "no")
		}
	}
}

func process(arr []int) bool {
	if len(arr) == 0 {
		return false
	} else if len(arr) == 1 {
		if arr[0] <= 1{
			return true
		} else {
			return false
		}
	}
	a, b := arr[0], arr[0]
	for _, v := range arr {
		if v > a {
			a = v
		} else if v > b {
			b = v
		}
	}
	return a-b <= 1
}

package main

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

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)

	defer out.Flush()

	var t, typeNum, element int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &typeNum)
		arr := make([]int, typeNum)
		for i := 0; i < typeNum; i++ {
			fmt.Fscan(in, &element)
			arr[i] = element
		}
		if process(arr) {
			fmt.Fprintln(out, "yes")
		} else {
			fmt.Fprintln(out, "no")
		}
	}
}

func process(arr []int) bool {
	if len(arr) == 0 {
		return false
	} else if len(arr) == 1 {
		return true
	}
	a, b := arr[0], arr[0]
	for _, v := range arr {
		if v > a {
			a = v
		} else if v > b {
			b = v
		}
	}
	return a-b <= 1
}

package main

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

type CF1660B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1660B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1660B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1660B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1660B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1660B
Date: 3/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/B
Problem: CF1660B
**/
func (in *CF1660B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		sum := int64(0)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			sum += int64(arr[i])
		}

		ans := false
		if n == 1 {
			if sum == 1 {
				ans = true
			}
		} else {
			sort.Ints(arr)
			ws := true

			diff := -1
			for i := n - 2; i >= 0; i-- {
				if arr[i+1]-arr[i] > 1 {
					if diff == arr[i] {
						continue
					}
					ws = false
					break
				}
				diff = arr[i+1] - arr[i]
			}

			ans = ws
		}

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

func NewCF1660B(r *bufio.Reader) *CF1660B {
	return &CF1660B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1660B(bufio.NewReader(os.Stdin)).Run()
}

package main

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

type CF1660B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1660B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1660B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1660B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1660B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1660B
Date: 3/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/B
Problem: CF1660B
**/
func (in *CF1660B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		sum := int64(0)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			sum += int64(arr[i])
		}

		ans := false
		if n == 1 {
			if sum == 1 {
				ans = true
			}
		} else {
			sort.Ints(arr)
			ws := true

			diff := -1
			for i := n - 2; i >= 0; i-- {
				if arr[i+1]-arr[i] > 1 {
					if diff == 1 && arr[i]==1 {
						continue
					}
					ws = false
					break
				}
				diff = arr[i+1] - arr[i]
			}

			ans = ws
		}

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

func NewCF1660B(r *bufio.Reader) *CF1660B {
	return &CF1660B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1660B(bufio.NewReader(os.Stdin)).Run()
}

package main

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

type CF1660B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1660B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1660B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1660B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1660B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1660B
Date: 3/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/B
Problem: CF1660B
**/
func (in *CF1660B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		sum := int64(0)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			sum += int64(arr[i])
		}

		ans := false
		if n == 1 {
			if sum == 1 {
				ans = true
			}
		} else {
			sort.Ints(arr)
			ws := true
			for i := n - 2; i >= 0; i-- {
				if arr[i+1]-arr[i] > 1 && arr[i] > 1 {
					ws = false
					break
				}
			}

			ans = ws
		}

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

func NewCF1660B(r *bufio.Reader) *CF1660B {
	return &CF1660B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1660B(bufio.NewReader(os.Stdin)).Run()
}

package main

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

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i > 0; i-- {
		n := read()
		if n == 1 {
			if read() != 1 {
				Fprintln(out, "NO")
			} else {
				Fprintln(out, "YES")
			}
			continue
		}
		res := read()
		for j := n - 1; j > 0; j-- {
			res = abs(res - read())
		}
		if res == 0 || res == 1 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i >= 0; i-- {
	    n := read()
	    if n == 1 {
	        Fprintln(out, "NO")
	        continue
	    }
	    res := read()
	    for j := n; j > 0; j-- {
	        res = abs(res - read())
	    }
	    if res == 0 || res == 1 {
	        Fprintln(out, "YES")
	    } else {
	        Fprintln(out, "NO")
	    }
	}
}

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


package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		ans := []int{}
		for i := 1; i <= n; i <<= 1 {
			ans = append(ans, i)
			n -= i
		}
		if n > 0 {
			ans = append(ans, n)
		}
		sort.Ints(ans)
		for i := len(ans) - 1; i > 0; i-- {
			ans[i] -= ans[i-1]
		}
		Fprintln(out, len(ans)-1)
		for _, v := range ans[1:] {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		ans := []int{}
		for i := 0; 1<<i <= n; i++ {
			ans = append(ans, 1<<i)
			n -= 1 << i
		}
		if n > 0 {
			ans = append(ans, n)
		}
		sort.Ints(ans)
		for i := len(ans) - 1; i > 0; i-- {
			ans[i] -= ans[i-1]
		}
		Fprintln(out, len(ans)-1)
		for _, v := range ans[1:] {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}
}

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


package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func main() {
	defer ww.Flush()
	var n, m int
	fmt.Fscan(rr, &n, &m)
	nums := make([]int, m)
	for i:=0;i<len(nums);i++ {
		fmt.Fscan(rr, &nums[i])
	}
	st := newLazySegmentTree(nums)
	var q int
	fmt.Fscan(rr, &q)
	outer:
	for qq:=0;qq<q;qq++ {
		var xs, ys, xf, yf, k int
		fmt.Fscan(rr, &xs, &ys, &xf, &yf, &k)
		if abs(ys - yf) % k != 0 || abs(xs - xf) %k != 0 {
			fmt.Fprintln(ww, "NO")
			continue outer
		}
		high := xs + (n - xs) / k * k
		if st.query(1, min(ys, yf), max(ys, yf)) >= high {
			fmt.Fprintln(ww, "NO")
		} else {
			fmt.Fprintln(ww, "YES")
		}
	}
}

type lazyST []struct {
	l, r int
	todo int
	lazy bool // 支持区间修改为某一个值
	sum  int // 根据需要修改
}

// 线段树定义的操作，可修改
func (lazyST) op(a, b int) int {
	return max(a, b)
}

// 根据子节点修改节点
func (t lazyST) maintain(o int) {
	lo, ro := t[o<<1], t[o<<1|1]
	t[o].sum = t.op(lo.sum, ro.sum)
}

// 根据数组构建线段树，下标从 1 开始
func (t lazyST) build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].sum = a[l-1]
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

// 对节点 o 表示的区间的所有元素加上 add
// 如果要实现区间修改为某一个值而不是加上某一个值的话，将 += 变为 = 即可
func (t lazyST) do(o int, add int) {
	to := &t[o]
	to.todo += add                     // % mod
	to.lazy = true
	to.sum += add // % mod
}

// 懒标记下放
func (t lazyST) spread(o int) {
	if t[o].lazy {
		add := t[o].todo
		t.do(o<<1, add)
		t.do(o<<1|1, add)
		t[o].todo = 0
		t[o].lazy = false
	}
}

// 对 o 表示的区间中属于 [l, r] 的元素进行修改
func (t lazyST) update(o, l, r int, add int) {
	if l <= t[o].l && t[o].r <= r {
		// 是 [l, r] 的子集，全部修改
		t.do(o, add)
		return
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		t.update(o<<1, l, r, add)
	}
	if m < r {
		t.update(o<<1|1, l, r, add)
	}
	t.maintain(o)
}

// o=1  [l,r] 1<=l<=r<=n
func (t lazyST) query(o, l, r int) int {
	if l <= t[o].l && t[o].r <= r {
		return t[o].sum
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if r <= m {
		return t.query(o<<1, l, r)
	}
	if m < l {
		return t.query(o<<1|1, l, r)
	}
	vl := t.query(o<<1, l, r)
	vr := t.query(o<<1|1, l, r)
	return t.op(vl, vr)
}

func (t lazyST) queryAll() int { return t[1].sum }

// a 从 0 开始
func newLazySegmentTree(a []int) lazyST {
	t := make(lazyST, 4*len(a))
	t.build(a, 1, 1, len(a))
	return t
}

func abs(a int) int {if a < 0 {return -a} else {return a}}
func min(a, b int) int {if a < b {return a} else {return b}}
func max(a, b int) int {if a > b {return a} else {return b}}

package main

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

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

	n, m := readTwoNums(reader)

	A := readNNums(reader, m)

	q := readNum(reader)

	Q := make([][]int, q)
	for i := 0; i < q; i++ {
		Q[i] = readNNums(reader, 5)
	}

	res := solve(n, m, A, Q)

	var buf bytes.Buffer

	for i := 0; i < q; i++ {
		if res[i] {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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 solve(height int, m int, A []int, Q [][]int) []bool {

	arr := make([]int, 2*m)
	copy(arr[m:], A)

	for i := m - 1; i > 0; i-- {
		arr[i] = max(arr[2*i], arr[2*i+1])
	}

	get := func(l int, r int) int {
		var res int
		l += m
		r += m

		for l < r {
			if l&1 == 1 {
				res = max(res, arr[l])
				l++
			}
			if r&1 == 1 {
				r--
				res = max(res, arr[r])
			}
			l >>= 1
			r >>= 1
		}
		return res
	}

	check := func(a, b []int, k int) bool {
		y1, x1 := a[0], a[1]
		x1--
		y2, x2 := b[0], b[1]
		x2--
		if x1%k != x2%k || y1%k != y2%k {
			return false
		}
		h := get(min(x1, x2), max(x1, x2)+1)

		// h >= min(y1, y2)
		y := max(y1, y2)
		// y + k * cnt <= height
		cnt := (height - y) / k
		y += cnt * k
		return y > h
	}

	ans := make([]bool, len(Q))

	for i, cur := range Q {
		ans[i] = check(cur[:2], cur[2:4], cur[4])
	}

	return ans
}

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
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var a [200005]int
type Node struct{
	v int
	l int
	r int
	left *Node
	right *Node
}
func max(x,y int)int{
	if x>y{
		return x
	}
	return y
}
func abs(x int)int{
	if x<0{
		return -x
	}
	return x
}
func build(x *Node, l, r int){
	x.l = l
	x.r = r
	mid := (l+r)>>1
	if l == r{
		x.v=a[mid]
		return
	}
	x.left = &Node{}
	x.right = &Node{}
	build(x.left,l,mid)
	build(x.right,mid+1,r)
	x.v = max(x.left.v,x.right.v)
}
func getMax(x *Node, l, r int) int{
	if(l<=x.l&&r>=x.r){
		return x.v
	}
	if r<x.l||l>x.r{
		return -1
	}
	lv := getMax(x.left,l,r)
	rv := getMax(x.right,l,r)
	return max(lv,rv)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, m int
	fmt.Fscan(in,&n,&m)
	for i:=1;i<=m;i++{
		fmt.Fscan(in,&a[i])
	}
	root := &Node{}
	build(root,1,m)
	var q int
	fmt.Fscan(in,&q)
	for i:=1;i<=q;i++{
		var x1,y1,x2,y2,k int
		fmt.Fscan(in,&x1,&y1,&x2,&y2,&k)
		yota := (n-x1)/k
		h := x1 + yota * k
		if abs(h-x2)%k!=0 || abs(y1-y2)%k!=0{
			fmt.Fprintln(out,"NO")
			continue
		}
		if y1==y2{
			fmt.Fprintln(out,"YES")
			continue
		}
		if y1>y2{
			tmp := y1
			y1 = y2
			y2 = tmp
		}
		if getMax(root,y1,y2) >= h{
			fmt.Fprintln(out,"NO")
		}else{
			fmt.Fprintln(out,"YES")
		}
	}
}

package main

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

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(in io.Reader, out io.Writer) {
	var t int = 1
	// fmt.Fscan(in, &t)
	for ti := 0; ti < t; ti++ {
		var n, m int
		fmt.Fscan(in, &n, &m)
		b := make([]int, m)
		for i := range b {
			fmt.Fscan(in, &b[i])
		}
		var q int
		fmt.Fscan(in, &q)
		c := make([][5]int, q)
		for i := range c {
			fmt.Fscan(in, &c[i][0], &c[i][1], &c[i][2], &c[i][3], &c[i][4])
		}
		w1 := do(n, m, b, q, c)
		for _, v := range w1 {
			fmt.Fprintln(out, v)
		}
	}
}

func do(n, m int, b []int, q int, c [][5]int) []string {
	t := build(1, m, b)
	do1 := func(x1, y1, x2, y2, k int) string {
		// log.Print(x1, y1, x2, y2, k)
		if y1 > y2 {
			x1, y1, x2, y2 = x2, y2, x1, y1
		}
		x1 += (n - x1) / k * k
		x2 += (n - x2) / k * k
		// log.Print(x1, x2)
		if (y2-y1)%k != 0 || x1 != x2 {
			return "NO"
		}
		v := query(t, y1, y2)
		// log.Print(v)
		if x1 <= v {
			return "NO"
		}
		return "YES"
	}
	ans := make([]string, q)
	for i, c := range c {
		ans[i] = do1(c[0], c[1], c[2], c[3], c[4])
	}
	return ans
}

type node struct {
	l, r   int
	ln, rn *node
	v      int
}

func build(l, r int, b []int) *node {
	n := &node{}
	n.l = l
	n.r = r
	if l == r {
		n.v = b[l-1]
		return n
	}
	m := (l + r) / 2
	n.ln = build(l, m, b)
	n.rn = build(m+1, r, b)
	n.v = n.ln.v
	if n.v < n.rn.v {
		n.v = n.rn.v
	}
	return n
}

func query(n *node, l, r int) int {
	if l <= n.l && n.r <= r {
		return n.v
	}
	m := (n.l + n.r) / 2
	if r <= m {
		return query(n.ln, l, r)
	} else if l >= m+1 {
		return query(n.rn, l, r)
	} else {
		lv := query(n.ln, l, m)
		rv := query(n.rn, m+1, r)
		if lv > rv {
			return lv
		}
		return rv
	}
}


package main

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

var (
	MOD int64 = int64(998244353)
)

func addEdge(g [][]int, from, to int) {
	if len(g[from]) <= 0 {
		g[from] = make([]int, 0)
	}
	g[from] = append(g[from], to)
}
func dfs(g [][]int, visit []int, root int, sum *int64, s *int64, f int) bool {
	visit[root] = f
	f++
	if f == 3 {
		f = 1
	}
	*sum = *sum + 1
	if f == 1 {
		*s = *s + 1
	}
	for _, next := range g[root] {
		if visit[next] == 0 {
			if dfs(g, visit, next, sum, s, f) == false {
				return false
			}
		} else if visit[next] != f {
			return false
		}
	}
	return true
}
func mi2(n int64) int64 {
	var d int64 = 2
	var ans int64 = 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = (ans * d) % MOD
		}
		n >>= 1
		d = (d * d) % MOD
	}
	return ans
}
func solve(sum, left int64) int64 {
	if sum == 1 {
		return int64(3)
	}
	ans1 := mi2(left)
	ans2 := mi2(sum - left)
	return (ans1 + ans2) % MOD
}
func main() {

	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	for i := 1; i <= t; i++ {
		var n, m int
		fmt.Fscanf(buf, "%d %d\n", &n, &m)
		visit := make([]int, n+1)
		g := make([][]int, n+1)
		for j := 1; j <= m; j++ {
			var from, to int
			fmt.Fscanf(buf, "%d %d\n", &from, &to)
			addEdge(g, from, to)
			addEdge(g, to, from)
		}
		//	fmt.Println(g)
		var ans int64 = 0
		var sum int64 = 0
		var left int64 = 0
		for j := 1; j <= n; j++ {
			if visit[j] == 0 {
				sum = 0
				left = 0
				ok := dfs(g, visit, j, &sum, &left, 1)
				if ok == false {
					ans = 0
					break
				}
				var tmp int64 = solve(sum, left)
				if ans == 0 {
					ans = tmp
				} else {
					ans = (ans * tmp) % MOD
				}
			}
		}

		fmt.Printf("%d\n", ans)
	}
}

/*
4 2
1 2
3 4
2 0

5 4
1 2
3 4
4 5
5 3
5 1
1 2
*/

package main

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

type Node struct {
	value int
	neighbor []int
}

func (n *Node) AddNeighbor(neighbor int) {
	n.neighbor = append(n.neighbor, neighbor)
}

var nodes []Node

const MOD = 998244353

func calculateWays() int64 {
	var ways int64 = 1
	for i, node := range nodes {
		if node.value == 0 {
			subgraphWays := getSubGraphWays(i)
			if subgraphWays == 0 {
				return 0
			}
			ways = (ways * subgraphWays) % MOD
		}
	}
	return ways
}

func getSubGraphWays(start int) int64 {
	oneCount := 0
	twoCount := 0
	valid := assignValue(start, 1, &oneCount, &twoCount)
	if !valid {
		return 0
	}
	// 2^b + 2^a
	return (powerTwo(oneCount) + powerTwo(twoCount)) % MOD
}

func assignValue(start int, value int, oneCount *int, twoCount *int) bool {
	nodes[start].value = value
	if value == 1 {
		*oneCount += 1
	} else {
		*twoCount += 1
	}
	for _, neighbor := range nodes[start].neighbor {
		n := nodes[neighbor]
		if n.value == value {
			return false
		}
		if n.value == 0 {
			if !assignValue(neighbor, 3 - value, oneCount, twoCount) {
				return false
			}
		}
	}
	return true
}

func powerTwo(a int) int64 {
	if a == 0 {
		return 1
	}
	res := powerTwo(a / 2)
	res = (res * res) % MOD
	if a % 2 == 1 {
		res = (res * 2) % MOD
	}
	return res
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)

	var t int
	for _, err := fmt.Fscan(stdin, &t); err == nil; _, err = fmt.Fscan(stdin, &t) {
		for ti := 0; ti < t; ti++ {
			var n, m int
			fmt.Fscan(stdin, &n, &m)

			nodes = make([]Node, n)
			for i := 0; i < m; i++ {
				var u, v int
				fmt.Fscan(stdin, &u, &v)
				u--
				v--
				nodes[u].AddNeighbor(v)
				nodes[v].AddNeighbor(u)
			}
			ways := calculateWays()
			fmt.Fprintf(stdout, "%d\n", ways)
			stdout.Flush()
		}
	}
}

package main

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

var (
	MOD int64 = int64(998244353)
)

func addEdge(g [][]int, from, to int) {
	if len(g[from]) <= 0 {
		g[from] = make([]int, 0)
	}
	g[from] = append(g[from], to)
}
func dfs(g [][]int,visit []int, root int, sum *int64, s *int64, f int)bool {
	visit[root] = f
	f++
	if f==3{
		f=1
	}
	*sum = *sum+1
	if f== 1{
		*s = *s+1
	}
	for _,next := range g[root]{
		if visit[next] == 0{
			if dfs(g,visit,next,sum,s,f) == false{
				return false
			}
		}else if visit[next] != f{
			return false
		}
	}
	return true
}
func mi2(n int64) int64 {
	var d int64 = 2
	var ans int64 = 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = (ans * d) % MOD
		}
		n >>= 1
		d = (d * d) % MOD
	}
	return ans
}
func solve(sum, left int64) int64 {
	if sum == 1 {
		return int64(3)
	}
	ans1 := mi2(left)
	ans2 := mi2(sum-left)
	return (ans1+ans2)%MOD
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	for i := 1; i <= t; i++ {
		var n, m int
		fmt.Fscanf(buf, "%d %d\n", &n, &m)
		visit := make([]int, n+1)
		g := make([][]int, n+1)
		for j := 1; j <= m; j++ {
			var from, to int
			fmt.Fscanf(buf, "%d %d\n", &from, &to)
			addEdge(g, from, to)
			addEdge(g, to, from)
		}
	//	fmt.Println(g)
		var ans int64 = 0
		var sum int64 = 0
		var left int64 = 0
		for j := 1; j <= n; j++ {
			if visit[j] == 0 {
				sum = 0
				left = 0
				ok := dfs(g,visit, j, &sum, &left, 1)
				if ok == false{
					continue
				}
				var tmp int64 = solve(sum, left)
				if ans == 0 {
					ans = tmp
				} else {
					ans = (ans * tmp) % MOD
				}
			}
		}

		fmt.Printf("%d\n", ans)
	}
}
/*
4 2
1 2
3 4
2 0
*/


package main

import "fmt"

func main() {
	var n, a, b, k, i int64
	_, err := fmt.Scan(&n)
	if err != nil {
		panic(err)
	}
	for i = 0; i < n; i++ {
		_, err = fmt.Scan(&a, &b, &k)
		if err != nil {
			panic(err)
		}
		res := (a-b)*(k/2) + a*(k%2)
		fmt.Println(res)
	}
}

package main

import "fmt"

func frogJump(a, b, k int64) int64 {
	res := (k + 1) / 2 * a
	res -= k / 2 * b
	return res
}

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

	ans := make([]int64, t)
	for i := range ans {
		var a, b, k int64
		fmt.Scan(&a, &b, &k)

		ans[i] = frogJump(a, b, k)
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}

package main

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

func frogJump(a, b, k int64) int64 {
	res := (k + 1) / 2 * a
	res -= k / 2 * b
	return res
}

func main() {
	io := newIo()
	defer io.flush()

	t := io.nextInt()
	ans := make([]int64, t)
	for i := range ans {
		a := io.nextInt()
		b := io.nextInt()
		k := io.nextInt()
		ans[i] = frogJump(a, b, k)
	}

	for _, v := range ans {
		io.printf("%d\n", v)
	}
}

type _io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (_io *_io) flush() {
	_ = _io.writer.Flush()
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

func (_io *_io) nextInt() int64 {
	i, _ := strconv.ParseInt(_io.next(), 10, 64)
	return i
}

func (_io *_io) printf(format string, a ...interface{}) {
	fmt.Fprintf(_io.writer, format, a...)
}

package main

import "fmt"

func main() {
	var index int64
	var r, l, k int64
	fmt.Scan(&index)
	for ; index > 0; index-- {
		fmt.Scan(&r, &l, &k)
		fmt.Printf("%v\n", ((k+1)/2*r - k/2*l))
	}

}

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

type query struct {
	a int64
	b int64
	k int64
}

func main() {
	defer writer.Flush()

	var t int64
	scanf("%d\n", &t)
	queries := make([]query, t)
	for i := int64(0); i < t; i++ {
		scanf("%d %d %d\n", &(queries[i].a), &(queries[i].b), &(queries[i].k))
	}

	for i, q := range queries {
		if i == len(queries)-1 {
			printf("%d", q.a*((q.k+1)/2)-q.b*(q.k/2))
		} else {
			printf("%d\n", q.a*((q.k+1)/2)-q.b*(q.k/2))
		}
	}
}

package main

import "fmt"

func main() {

	var n int64

	fmt.Scan(&n)

	for ;n != 0; n-- {

		var a,b,k int64

		fmt.Scan(&a, &b, &k)

		if k&1 == 0 {
			fmt.Println(int64((k/2)*(a-b)))
		} else {
			fmt.Println(int64(((k-1)/2)*(a-b) + a))
		}
	}
}

package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n, a, b, k int64
	fmt.Fscan(stdin, &n)
	for n > 0 {
		n--
		fmt.Fscan(stdin, &a, &b, &k)
		fmt.Println((k / 2) * (a - b) + a * (k % 2))
	}
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    for n > 0 {
        n--
        var k, x, y int
        fmt.Scanf("%d %d %d\n", &x, &y, &k)
        var cnt int64 = int64(x - y) * int64(k / 2)
        if k % 2 == 1 {
            cnt += int64(x)
        }
        fmt.Println(cnt)
    }
}

package main

import "fmt"

type request struct {
	a int64
	b int64
	k int64
}

func main() {
	var (
		requests [1000]request
		nReq     int64
		i        int64
	)
	fmt.Scanln(&nReq)
	for i = 0; i < nReq; i++ {
		fmt.Scanln(&requests[i].a, &requests[i].b, &requests[i].k)
	}
	for i = 0; i < nReq; i++ {
		fmt.Println(requests[i].b*(requests[i].k/-2) + requests[i].a*(requests[i].k-requests[i].k/2))
	}
}

package main

import "fmt"

func main() {

	var t,a,b,k,res,i int64
	fmt.Scanln(&t)
	for i=0; i<t;i++ {
		fmt.Scanln(&a,&b,&k)
		res = a*(k/2)+(-b)*(k/2)
		if k%2==1 {
			res+=a
		}
		fmt.Println(res)
	}

}

package main

import (
    "fmt"
)

func main() {
    var t int
    var a, b, k int64
    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        fmt.Scan(&a, &b, &k)
        n := k / 2
        fmt.Println(n*a - n*b + (k%2)*a)
    }
}

package main

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var t int
    var a, b, k int64
    fmt.Fscan(stdin, &t)
    for i := 0; i < t; i++ {
        fmt.Fscan(stdin, &a, &b, &k)
        n := k / 2
        fmt.Println(n*a - n*b + (k%2)*a)
    }
}

package main

import (
    "fmt"
)

func main() {
    var n int64
    fmt.Scan(&n)
    for i := int64(0); i < n; i++ {
        var a, b, k int64
        fmt.Scan(&a, &b, &k)
        res := (a * (k / 2)) - (b * (k / 2))
        if k % 2 == 1 {
            res += a
        }
        fmt.Println(res)
    }
}

package main

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

func main() {
	var t int
	var a, b, k int64
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &a, &b, &k)
		m := k / 2
		ans := m*a - m*b
		if k%2 == 1 {
			ans += a
		}
		fmt.Println(ans)
	}
}

package main

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

func calcFrog(a, b, k int64) (x int64) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

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

	text, _ = reader.ReadString('\n')
	text = strings.TrimSpace(text)
	n64, _ := strconv.ParseInt(text, 10, 64)
	n := n64

	frogs := make([][3]int64, n)

	for i := int64(0); i < n; i++ {
		text, _ = reader.ReadString('\n')
		text = strings.TrimSpace(text)
		f := [3]int64{}
		for j, v := range strings.Split(text, " ") {
			vi, _ := strconv.ParseInt(v, 10, 64)
			f[j] = vi
		}
		frogs[i] = f
	}

	for _, f := range frogs {
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}
}

package main

import (
	"fmt"
)

func calcFrog(a, b, k int64) (x int64) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	frogs := make([][3]int64, n)

	for i := int64(0); i < n; i++ {
		f := [3]int64{}
		fmt.Scan(&f[0], &f[1], &f[2])
		frogs[i] = f
	}

	for _, f := range frogs {
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}
}

// A. Frog Jumping
/*
A frog is currently at the point 0 on a coordinate axis 𝑂𝑥. It jumps by the following algorithm: the first jump is 𝑎 units to the right, the second jump is 𝑏 units to the left, the third jump is 𝑎 units to the right, the fourth jump is 𝑏 units to the left, and so on.

Formally:

    if the frog has jumped an even number of times (before the current jump), it jumps from its current position 𝑥 to position 𝑥+𝑎;
    otherwise it jumps from its current position 𝑥 to position 𝑥−𝑏.

Your task is to calculate the position of the frog after 𝑘 jumps.

But... One more thing. You are watching 𝑡 different frogs so you have to answer 𝑡 independent queries.

Input
The first line of the input contains one integer 𝑡 (1≤𝑡≤1000) — the number of queries.

Each of the next 𝑡 lines contain queries (one query per line).

The query is described as three space-separated integers 𝑎,𝑏,𝑘 (1≤𝑎,𝑏,𝑘≤109) — the lengths of two types of jumps and the number of jumps, respectively.

Output
Print 𝑡 integers. The 𝑖-th integer should be the answer for the 𝑖-th query.

Example
Input
6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999

Output
8
198
-17
2999999997
0
1

Note
In the first query frog jumps 5 to the right, 2 to the left and 5 to the right so the answer is 5−2+5=8.

In the second query frog jumps 100 to the right, 1 to the left, 100 to the right and 1 to the left so the answer is 100−1+100−1=198.

In the third query the answer is 1−10+1−10+1=−17.

In the fourth query the answer is 109−1+109−1+109−1=2999999997.

In the fifth query all frog's jumps are neutralized by each other so the answer is 0.

The sixth query is the same as the fifth but without the last jump so the answer is 1.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")

		a, _ := strconv.ParseInt(strings.TrimSpace(arr[0]), 10, 64)
		b, _ := strconv.ParseInt(strings.TrimSpace(arr[1]), 10, 64)
		k, _ := strconv.ParseInt(strings.TrimSpace(arr[2]), 10, 64)

		r, q := k%2, k/2
		if r == 0 {
			fmt.Println((q * a) - (q * b))
		} else {
			fmt.Println(((q + 1) * a) - (q * b))
		}
	}
}

package main

import (
	"fmt"
)

func calcFrog(a, b, k int64) (x int64) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	frogs := make([][3]int64, n)

	for i := int64(0); i < n; i++ {
		f := [3]int64{}
		for j := 0; j < 3; j++ {
			fmt.Scan(&f[j])
		}
		frogs[i] = f
	}

	for _, f := range frogs {
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		var a, b, k int64
		fmt.Scan(&a, &b, &k)
		var n int64 = k/2
		var i int64 = a
		if k%2 == 0 {
			i -= b
			n--
		}
		i -= b*n
		i += a*n
		fmt.Println(i)
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int64
	fmt.Scan(&n)

	for ;n > 0;n-- {
		var a, b, k int64
		fmt.Scan(&a, &b, &k)
		var n int64 = k/2
		var i int64 = a
		if k%2 == 0 {
			i -= b
			n--
		}
		i -= b*n
		i += a*n
		fmt.Println(i)
	}
}

package main

import "fmt"

func main() {
    var t,a,b,k int64
    fmt.Scan(&t)
    for ;t>0;t-- {
        fmt.Scan(&a, &b, &k)
        fmt.Printf("%v\n", ((k+1)/2*a - k/2*b))
    }
}

package main

import (
	"fmt"
)

func main() {
	var input int
	fmt.Scanln(&input)
	i := 0
	for i < input {
		var k, a, b int64
		fmt.Scanln(&a, &b, &k)
		if t := k / 2; k%2 == 1 {
			fmt.Println(t*(a-b) + a)
		} else {
			fmt.Println(t * (a - b))
		}
		i += 1
	}
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

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

func scanBytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func scanInt64() int64 {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v
}

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

func scanInts(n int) []int {
	l := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.Atoi(scanner.Text())
	}

	return l
}

func scanInts64(n int64) []int64 {
	l := make([]int64, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}

	return l
}

func scanBool() bool {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v == 1
}

func scanBools(n int64) []bool {
	l := make([]bool, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		l[i] = v == 1
	}

	return l
}

func main() {
	n := scanInt()

	for i := 0; i < n; i++ {
		a, b, k := scanInt64(), scanInt64(), scanInt64()
		cnt := int64(math.Ceil(float64(k) / 2.0))
		dist := a*cnt - b*(k-cnt)
		fmt.Println(dist)
	}
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}

	return -a
}

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

	return b
}

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

	return b
}

package main

import "fmt"

func main() {

	var t,a,b,k,res int
	fmt.Scanln(&t)
	for i :=0; i<t;i++ {
		fmt.Scanln(&a,&b,&k)
		res = a*(k/2)+(-b)*(k/2)
		if k%2==1 {
			res+=a
		}
		fmt.Println(res)
	}

}

package main

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

func main() {
	var t, a, b, k int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &a, &b, &k)
		m := k / 2
		ans := m*a - m*b
		if k%2 == 1 {
			ans += a
		}
		fmt.Println(ans)
	}
}

// A. Frog Jumping
/*
A frog is currently at the point 0 on a coordinate axis 𝑂𝑥. It jumps by the following algorithm: the first jump is 𝑎 units to the right, the second jump is 𝑏 units to the left, the third jump is 𝑎 units to the right, the fourth jump is 𝑏 units to the left, and so on.

Formally:

    if the frog has jumped an even number of times (before the current jump), it jumps from its current position 𝑥 to position 𝑥+𝑎;
    otherwise it jumps from its current position 𝑥 to position 𝑥−𝑏.

Your task is to calculate the position of the frog after 𝑘 jumps.

But... One more thing. You are watching 𝑡 different frogs so you have to answer 𝑡 independent queries.

Input
The first line of the input contains one integer 𝑡 (1≤𝑡≤1000) — the number of queries.

Each of the next 𝑡 lines contain queries (one query per line).

The query is described as three space-separated integers 𝑎,𝑏,𝑘 (1≤𝑎,𝑏,𝑘≤109) — the lengths of two types of jumps and the number of jumps, respectively.

Output
Print 𝑡 integers. The 𝑖-th integer should be the answer for the 𝑖-th query.

Example
Input
6
5 2 3
100 1 4
1 10 5
1000000000 1 6
1 1 1000000000
1 1 999999999

Output
8
198
-17
2999999997
0
1

Note
In the first query frog jumps 5 to the right, 2 to the left and 5 to the right so the answer is 5−2+5=8.

In the second query frog jumps 100 to the right, 1 to the left, 100 to the right and 1 to the left so the answer is 100−1+100−1=198.

In the third query the answer is 1−10+1−10+1=−17.

In the fourth query the answer is 109−1+109−1+109−1=2999999997.

In the fifth query all frog's jumps are neutralized by each other so the answer is 0.

The sixth query is the same as the fifth but without the last jump so the answer is 1.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")

		a, _ := strconv.Atoi(strings.TrimSpace(arr[0]))
		b, _ := strconv.Atoi(strings.TrimSpace(arr[1]))
		k, _ := strconv.Atoi(strings.TrimSpace(arr[2]))

		r, q := k%2, k/2
		if r == 0 {
			fmt.Println((q * a) - (q * b))
		} else {
			fmt.Println(((q + 1) * a) - (q * b))
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b, k, i int
	_, err := fmt.Scan(&n)
	if err != nil {
		panic(err)
	}
	for i = 0; i < n; i++ {
		_, err = fmt.Scan(&a, &b, &k)
		if err != nil {
			panic(err)
		}
		res := (a-b)*(k/2) + a*(k%2)
		fmt.Println(res)
	}
}

package main

import "fmt"

func main() {
	var n, a, b, k int
	_, err := fmt.Scan(&n)
	if err != nil {
		panic(err)
	}
	for i := 0; i < n; i++ {
		_, err = fmt.Scan(&a, &b, &k)
		if err != nil {
			panic(err)
		}
		res := (b-a)*(k/2) + a*(k%2)
		fmt.Println(res)
	}
}

package main

import "fmt"

func main() {
	var n, a, b, k int
	_, err := fmt.Scanln(&n)
	if err != nil {
		panic(err)
	}
	for i := 0; i < n; i++ {
		_, err = fmt.Scanln(&a, &b, &k)
		if err != nil {
			panic(err)
		}
		res := (a-b)*(k/2) + a*(k%2)
		fmt.Println(res)
	}
}

package main

import "fmt"

func frogJump(a, b, k int) int {
	res := 0
	res += (k + 1) / 2 * a
	res -= k / 2 * b
	return res
}

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

	ans := make([]int, t)
	for i := range ans {
		var a, b, k int
		fmt.Scan(&a, &b, &k)

		ans[i] = frogJump(a, b, k)
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}

package main

import "fmt"

func main() {
	var index int
	var r, l, k int
	fmt.Scan(&index)
	for ; index > 0; index-- {
		fmt.Scan(&r, &l, &k)
		fmt.Printf("%v\n", ((k+1)/2*r - k/2*l))
	}

}

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

type query struct {
	a int
	b int
	k int
}

func main() {
	defer writer.Flush()

	var t int
	fmt.Scanf("%d\n", &t)
	queries := make([]query, t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &(queries[i].a), &(queries[i].b), &(queries[i].k))
	}

	// fmt.Printf("Queries=%v\n", queries)

	for _, q := range queries {
		fmt.Printf("%d\n", q.a*((q.k+1)/2)-q.b*(q.k/2))
	}
}

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

type query struct {
	a int
	b int
	k int
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	queries := make([]query, t)
	for i := 0; i < t; i++ {
		scanf("%d %d %d\n", &(queries[i].a), &(queries[i].b), &(queries[i].k))
	}

	for i, q := range queries {
		if i == len(queries)-1 {
			printf("%d", q.a*((q.k+1)/2)-q.b*(q.k/2))
		} else {
			printf("%d\n", q.a*((q.k+1)/2)-q.b*(q.k/2))
		}
	}
}

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

type query struct {
	a int
	b int
	k int
}

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	queries := make([]query, t)
	for i := 0; i < t; i++ {
		scanf("%d %d %d\n", &(queries[i].a), &(queries[i].b), &(queries[i].k))
	}

	for _, q := range queries {
		printf("%d\n", q.a*((q.k+1)/2)-q.b*(q.k/2))
	}
}

package main

import "fmt"

func main() {

	var n int

	fmt.Scan(&n)

	for ;n != 0; n-- {

		var a,b,k int

		fmt.Scan(&a, &b, &k)

		if k&1 == 0 {
			fmt.Println((k/2)*(a-b))
		} else {
			fmt.Println(((k-1)/2)*(a-b) + a)
		}
	}
}

package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n, a, b, k int64
	fmt.Scan(stdin, &n)
	for n > 0 {
		n--
		fmt.Scan(stdin, &a, &b, &k)
		fmt.Println((k / 2) * (a - b) + a * (k % 2))
	}
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    for n > 0 {
        n--
        var k, x, y int
        fmt.Scanf("%d %d %d\n", &x, &y, &k)
        var cnt int = (x - y) * (k / 2)
        if k % 2 == 1 {
            cnt += x
        }
        fmt.Println(cnt)
    }
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scanf("%d\n", &n)
    for n > 0 {
        n--
        var k, x, y int
        fmt.Scanf("%d %d %d\n", &x, &y, &k)
        cnt := (x - y) * (k / 2)
        if k % 2 == 1 {
            cnt += x
        }
        fmt.Println(cnt)
    }
}

package main

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

func calcFrog(a int, b int, k int) (x int) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

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

	text, _ = reader.ReadString('\n')
	text = strings.TrimSpace(text)
	n64, _ := strconv.ParseInt(text, 10, 64)
	n := int(n64)

	frogs := make([][3]int, n)

	for i := 0; i < n; i++ {
		text, _ = reader.ReadString('\n')
		text = strings.TrimSpace(text)
		f := [3]int{}
		for j, v := range strings.Split(text, " ") {
			vi, _ := strconv.ParseInt(v, 10, 64)
			f[j] = int(vi)
		}
		frogs[i] = f
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}

	//for _, f := range frogs {
	//	fmt.Println(calcFrog(f[0], f[1], f[2]))
	//}
}

package main

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

func calcFrog(a int, b int, k int) (x int) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

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

	text, _ = reader.ReadString('\n')
	text = strings.TrimSpace(text)
	n64, _ := strconv.ParseInt(text, 10, 64)
	n := int(n64)

	frogs := make([][3]int, n)

	for i := 0; i < n; i++ {
		text, _ = reader.ReadString('\n')
		text = strings.TrimSpace(text)
		f := [3]int{}
		for j, v := range strings.Split(text, " ") {
			vi, _ := strconv.ParseInt(v, 10, 64)
			f[j] = int(vi)
		}
		frogs[i] = f
	}

	for _, f := range frogs {
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}
}

package main

import (
	"fmt"
)

func calcFrog(a, b, k int64) (x int64) {
	opC := k / 2
	x += a * opC
	x -= b * opC
	if (opC * 2) != k {
		x += a
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	frogs := make([][3]int64, n)

	for i := int64(0); i < n; i++ {
		f := [3]int64{}
		fmt.Scan(&f)
		frogs[i] = f
	}

	for _, f := range frogs {
		fmt.Println(calcFrog(f[0], f[1], f[2]))
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		var a, b, k int
		fmt.Scan(&a, &b, &k)
		n := k/2
		i := a
		i -= b*n
		i += a*n
		if k%2 == 0 {
			i -= b
		}
		fmt.Println(i)
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		i := 0
		var a, b, k int
		fmt.Scan(&a, &b, &k)
		for j := 0; j < k; j+=2 {
				i += a
				if j < k - 2 {
					i -= b
				}
		}
		fmt.Println(i)
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		i := 0
		var a, b, k int
		fmt.Scan(&a, &b, &k)
		n := k/2
		i += a*n
		i -= b*n
		if k%2 != 0 {
			i -= b
		}
		fmt.Println(i)
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		var a, b, k int
		fmt.Scan(&a, &b, &k)
		n := k/2
		i := a
		if k%2 == 0 {
			i -= b
			n--
		}
		i -= b*n
		i += a*n
		fmt.Println(i)
	}
}

package main

import (
	"fmt"
	"os"
)

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*f, oldStdin := settest()
	defer f.Close()
	defer func() { os.Stdin = oldStdin }()*/

	var n int
	fmt.Scan(&n)

	for ;n > 0;n-- {
		i := 0
		var a, b, k int
		fmt.Scan(&a, &b, &k)
		for j := 0; j < k; j+=2 {
				i += a
				if j < k - 1 {
					i -= b
				}
		}
		fmt.Println(i)
	}
}

package main

import "fmt"

func main() {
    var t,a,b,k int
    fmt.Scan(&t)
    for ;t>0;t-- {
        fmt.Scan(&a, &b, &k)
        fmt.Printf("%v\n", ((k+1)/2*a - k/2*b))
    }
}

package main

import (
	"fmt"
)

func main() {
	var input int
	fmt.Scanln(&input)
	i := 0
	for i < input {
		var k, a, b int32
		fmt.Scanln(&a, &b, &k)
		if t := k / 2; k%2 == 1 {
			fmt.Println(t*(a-b) + a)
		} else {
			fmt.Println(t * (a - b))
		}
		i += 1
	}
}

package main

import (
	"fmt"
)

func main() {
	var input int
	fmt.Scanln(&input)
	i := 0
	for i < input {
		var k, a, b uint
		fmt.Scanln(&a, &b, &k)
		if t := k / 2; k%2 == 1 {
			fmt.Println(t*(a-b) + a)
		} else {
			fmt.Println(t * (a - b))
		}
		i += 1
	}
}

package main

import (
	"fmt"
)

func main() {
	var input int
	fmt.Scanln(&input)
	i := 0
	for i < input {
		var k, a, b int
		fmt.Scanln(&a, &b, &k)
		if t := k / 2; k%2 == 1 {
			fmt.Println(t*(a-b) + a)
		} else {
			fmt.Println(t * (a - b))
		}
		i += 1
	}
}


package main

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

type Worker struct {
	i, l, v, r int
}

type Event struct {
	t int
	*Worker
}

type Events []Event

func (a Events) Less(i, j int) bool {
	x, y := a[i], a[j]
	vx := x.v
	if x.t == -1 {
		vx = x.r
	}
	vy := y.v
	if y.t == -1 {
		vy = y.r
	}
	if vx != vy {
		return vx < vy
	}
	return x.t > y.t
}
func (a Events) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Events) Len() int      { return len(a) }

type SegTree struct {
	n int
	f, g, x []int
}

func NewSegTree(n int) *SegTree {
	t := &SegTree{
		n: n,
		f: make([]int, 2*n),
		g: make([]int, 2*n),
		x: make([]int, 2*n),
	}
	t.build(0, n)
	return t
}

func (t *SegTree) build(u, v int) {
	i := id(u, v)
	t.x[i] = u
	if u + 1 < v {
		d := mid(u, v)
		t.build(u, d)
		t.build(d, v)
	}
}

func id(u, v int) int {
	t := u + v - 1
	if u + 1 < v {
		t |= 1
	}
	return t
}

func mid(u, v int) int {
	return (u + v + 1) >> 1
}

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

func (t *SegTree) Inc(a, b, y int) {
	n := t.n
	f := t.f
	g := t.g
	x := t.x
//	fmt.Println("Inc", a, b, y)
	var inc func(u, v int)
	inc = func(u, v int) {
		i := id(u, v)
//		fmt.Println("inc", i, u, v, y)
		if b <= u || v <= a { return }
		if a <= u && v <= b {
			f[i] += y
			g[i] += y
			return
		}
		d := mid(u, v)
		l := id(u, d)
		r := id(d, v)
		inc(u, d)
		inc(d, v)
		if f[l] > f[r] {
			f[i] = g[i] + f[l]
			x[i] = x[l]
		} else {
			f[i] = g[i] + f[r]
			x[i] = x[r]
		}
	}
	inc(0, n)
}

func (t *SegTree) Max() (x, y int) {
	i := id(0, t.n)
	x, y = t.x[i], t.f[i]
	return
}

func Uniq(xs []int) []int {
	sort.Ints(xs)
	xx := xs[:0]
	for _, x := range xs {
		if len(xx) == 0 || xx[len(xx) - 1] != x {
			xx = append(xx, x)
		}
	}
	return xx
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]Worker, n)
	for i := range a {
		fmt.Fscanf(reader, "%d %d %d\n", &a[i].l, &a[i].v, &a[i].r)
		a[i].i = i
	}
//	fmt.Println(a)

	xs := make([]int, 2*n)
	for i := range a {
		xs[i+i+0] = a[i].l
		xs[i+i+1] = a[i].v
	}
	xx := Uniq(xs)
//	fmt.Println(xx)

	xid := func(x int) int {
		return sort.Search(len(xx), func(i int) bool {
			return xx[i] >= x
		})
	}

	es := make([]Event, 2*n)
	for i := range a {
		es[i+i+0] = Event{+1, &a[i]}
		es[i+i+1] = Event{-1, &a[i]}
	}
	sort.Sort(Events(es))

	ymax, x1, x2 := 0, 0, 0
	t := NewSegTree(len(xx))
	for _, e := range es {
//		fmt.Println(e.t, e.Worker)
		l := xid(e.l)
		r := xid(e.v)+1
		t.Inc(l, r, e.t)
//		fmt.Println(t.Max())
		if x, y := t.Max(); y > ymax {
			ymax = y
			x1 = xx[x]
			x2 = e.v
		}
	}
//	fmt.Println(ymax, x1, x2)

	ls := []int{}
	for i := range a {
		if a[i].l <= x1 && x1 <= a[i].v && a[i].v <= x2 && x2 <= a[i].r {
			ls = append(ls, a[i].i+1)
		}
	}
	pretty := fmt.Sprint(ls)
	fmt.Println(ymax)
	fmt.Println(pretty[1:len(pretty)-1])
}

package main

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

type Worker struct {
	i, l, v, r int
}

type Event struct {
	t int
	*Worker
}

type Events []Event

func (a Events) Less(i, j int) bool {
	x, y := a[i], a[j]
	vx := x.v
	if x.t == -1 {
		vx = x.r
	}
	vy := y.v
	if y.t == -1 {
		vy = y.r
	}
	if vx != vy {
		return vx < vy
	}
	return x.t > y.t
}
func (a Events) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Events) Len() int      { return len(a) }

type SegTree struct {
	n       int
	f, g, x []int
}

func NewSegTree(n int) *SegTree {
	t := &SegTree{
		n: n,
		f: make([]int, 2*n),
		g: make([]int, 2*n),
		x: make([]int, 2*n),
	}
	t.build(0, n)
	return t
}

func (t *SegTree) build(u, v int) {
	i := id(u, v)
	t.x[i] = u
	if u+1 < v {
		d := mid(u, v)
		t.build(u, d)
		t.build(d, v)
	}
}

func id(u, v int) int {
	t := u + v - 1
	if u+1 < v {
		t |= 1
	}
	return t
}

func mid(u, v int) int {
	return (u + v + 1) >> 1
}

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

func (t *SegTree) Inc(a, b, y int) {
	n := t.n
	f := t.f
	g := t.g
	x := t.x
	var inc func(u, v int)
	inc = func(u, v int) {
		i := id(u, v)
		if b <= u || v <= a {
			return
		}
		if a <= u && v <= b {
			f[i] += y
			g[i] += y
			return
		}
		d := mid(u, v)
		l := id(u, d)
		r := id(d, v)
		inc(u, d)
		inc(d, v)
		if f[l] > f[r] {
			f[i] = g[i] + f[l]
			x[i] = x[l]
		} else {
			f[i] = g[i] + f[r]
			x[i] = x[r]
		}
	}
	inc(0, n)
}

func (t *SegTree) Max() (x, y int) {
	i := id(0, t.n)
	x, y = t.x[i], t.f[i]
	return
}

func Uniq(xs []int) []int {
	sort.Ints(xs)
	xx := xs[:0]
	for _, x := range xs {
		if len(xx) == 0 || xx[len(xx)-1] != x {
			xx = append(xx, x)
		}
	}
	return xx
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]Worker, n)
	for i := range a {
		fmt.Fscanf(reader, "%d %d %d\n", &a[i].l, &a[i].v, &a[i].r)
		a[i].i = i
	}

	xs := make([]int, 2*n)
	for i := range a {
		xs[i+i+0] = a[i].l
		xs[i+i+1] = a[i].v
	}
	xx := Uniq(xs)

	xid := func(x int) int {
		return sort.Search(len(xx), func(i int) bool {
			return xx[i] >= x
		})
	}

	es := make([]Event, 2*n)
	for i := range a {
		es[i+i+0] = Event{+1, &a[i]}
		es[i+i+1] = Event{-1, &a[i]}
	}
	sort.Sort(Events(es))

	ymax, x1, x2 := 0, 0, 0
	t := NewSegTree(len(xx))
	for _, e := range es {
		l := xid(e.l)
		r := xid(e.v) + 1
		t.Inc(l, r, e.t)
		if x, y := t.Max(); y > ymax {
			ymax = y
			x1 = xx[x]
			x2 = e.v
		}
	}

	ls := []int{}
	for i := range a {
		if a[i].l <= x1 && x1 <= a[i].v && a[i].v <= x2 && x2 <= a[i].r {
			ls = append(ls, a[i].i+1)
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fprintln(writer, ymax)
	pretty := fmt.Sprint(ls)
	fmt.Fprintln(writer, pretty[1 : len(pretty)-1])
}

package main

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

type Worker struct {
	i, l, v, r int
}

type Event struct {
	t int
	*Worker
}

type Events []Event

func (a Events) Less(i, j int) bool {
	x, y := a[i], a[j]
	vx := x.v
	if x.t == -1 {
		vx = x.r
	}
	vy := y.v
	if y.t == -1 {
		vy = y.r
	}
	if vx != vy {
		return vx < vy
	}
	return x.t > y.t
}
func (a Events) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Events) Len() int      { return len(a) }

type SegTree struct {
	n int
	f, g, x []int
}

func NewSegTree(n int) *SegTree {
	t := &SegTree{
		n: n,
		f: make([]int, 2*n),
		g: make([]int, 2*n),
		x: make([]int, 2*n),
	}
	t.build(0, n)
	return t
}

func (t *SegTree) build(u, v int) {
	i := id(u, v)
	t.x[i] = u
	if u + 1 < v {
		d := mid(u, v)
		t.build(u, d)
		t.build(d, v)
	}
}

func id(u, v int) int {
	t := u + v - 1
	if u + 1 < v {
		t |= 1
	}
	return t
}

func mid(u, v int) int {
	return (u + v + 1) >> 1
}

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

func (t *SegTree) Inc(a, b, y int) {
	n := t.n
	f := t.f
	g := t.g
	x := t.x
//	fmt.Println("Inc", a, b, y)
	var inc func(u, v int)
	inc = func(u, v int) {
		i := id(u, v)
//		fmt.Println("inc", i, u, v, y)
		if b <= u || v <= a { return }
		if a <= u && v <= b {
			f[i] += y
			g[i] += y
			return
		}
		d := mid(u, v)
		l := id(u, d)
		r := id(d, v)
		inc(u, d)
		inc(d, v)
		if f[l] > f[r] {
			f[i] = g[i] + f[l]
			x[i] = x[l]
		} else {
			f[i] = g[i] + f[r]
			x[i] = x[r]
		}
	}
	inc(0, n)
}

func (t *SegTree) Max() (x, y int) {
	i := id(0, t.n)
	x, y = t.x[i], t.f[i]
	return
}

func Uniq(xs []int) []int {
	sort.Ints(xs)
	xx := xs[:0]
	for _, x := range xs {
		if len(xx) == 0 || xx[len(xx) - 1] != x {
			xx = append(xx, x)
		}
	}
	return xx
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]Worker, n)
	for i := range a {
		fmt.Fscanf(reader, "%d %d %d\n", &a[i].l, &a[i].v, &a[i].r)
		a[i].i = i
	}
//	fmt.Println(a)

	xs := make([]int, 2*n)
	for i := range a {
		xs[i+i+0] = a[i].l
		xs[i+i+1] = a[i].v
	}
	xx := Uniq(xs)
//	fmt.Println(xx)

	xid := func(x int) int {
		return sort.Search(len(xx), func(i int) bool {
			return xx[i] >= x
		})
	}

	es := make([]Event, 2*n)
	for i := range a {
		es[i+i+0] = Event{+1, &a[i]}
		es[i+i+1] = Event{-1, &a[i]}
	}
	sort.Sort(Events(es))

	ymax, x1, x2 := 0, 0, 0
	t := NewSegTree(len(xx))
	for _, e := range es {
//		fmt.Println(e.t, e.Worker)
		l := xid(e.l)
		r := xid(e.v)+1
		t.Inc(l, r, e.t)
//		fmt.Println(t.Max())
		if x, y := t.Max(); y > ymax {
			ymax = y
			x1 = xx[x]
			x2 = e.v
		}
	}
//	fmt.Println(ymax, x1, x2)

	ls := []int{}
	for i := range a {
		if a[i].v <= x1 && x1 <= a[i].v && a[i].v <= x2 && x2 <= a[i].r {
			ls = append(ls, a[i].i+1)
		}
	}
	pretty := fmt.Sprint(ls)
	fmt.Println(ymax)
	fmt.Println(pretty[1:len(pretty)-1])
}

package main

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

type Worker struct {
	i, l, v, r int
}

type Event struct {
	t int
	*Worker
}

type Events []Event

func (a Events) Less(i, j int) bool {
	x, y := a[i], a[j]
	vx := x.v
	if x.t == -1 {
		vx = x.r
	}
	vy := y.v
	if y.t == -1 {
		vy = y.r
	}
	if vx != vy {
		return vx < vy
	}
	return x.t > y.t
}
func (a Events) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Events) Len() int      { return len(a) }

type SegTree struct {
	n int
	f, g, x []int
}

func NewSegTree(n int) *SegTree {
	t := &SegTree{
		n: n,
		f: make([]int, 2*n),
		g: make([]int, 2*n),
		x: make([]int, 2*n),
	}
	t.build(0, n)
	return t
}

func (t *SegTree) build(u, v int) {
	i := id(u, v)
	t.x[i] = u
	if u + 1 < v {
		d := mid(u, v)
		t.build(u, d)
		t.build(d, v)
	}
}

func id(u, v int) int {
	t := u + v - 1
	if u + 1 < v {
		t |= 1
	}
	return t
}

func mid(u, v int) int {
	return (u + v + 1) >> 1
}

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

func (t *SegTree) Inc(a, b, y int) {
	n := t.n
	f := t.f
	g := t.g
	x := t.x
//	fmt.Println("Inc", a, b, y)
	var inc func(u, v int)
	inc = func(u, v int) {
		i := id(u, v)
//		fmt.Println("inc", i, u, v, y)
		if b <= u || v <= a { return }
		if a <= u && v <= b {
			f[i] += y
			g[i] += y
			return
		}
		d := mid(u, v)
		l := id(u, d)
		r := id(d, v)
		inc(u, d)
		inc(d, v)
		if f[l] > f[r] {
			f[i] = g[i] + f[l]
			x[i] = x[l]
		} else {
			f[i] = g[i] + f[r]
			x[i] = x[r]
		}
	}
	inc(0, n)
}

func (t *SegTree) Max() (x, y int) {
	i := id(0, t.n)
	x, y = t.x[i], t.f[i]
	return
}

func Uniq(xs []int) []int {
	sort.Ints(xs)
	xx := xs[:0]
	for _, x := range xs {
		if len(xx) == 0 || xx[len(xx) - 1] != x {
			xx = append(xx, x)
		}
	}
	return xx
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]Worker, n)
	for i := range a {
		fmt.Fscanf(reader, "%d %d %d\n", &a[i].l, &a[i].v, &a[i].r)
		a[i].i = i
	}
//	fmt.Println(a)

	xs := make([]int, 2*n)
	for i := range a {
		xs[i+i+0] = a[i].l
		xs[i+i+1] = a[i].v
	}
	xx := Uniq(xs)
//	fmt.Println(xx)

	xid := func(x int) int {
		return sort.Search(len(xx), func(i int) bool {
			return xx[i] >= x
		})
	}

	es := make([]Event, 2*n)
	for i := range a {
		es[i+i+0] = Event{+1, &a[i]}
		es[i+i+1] = Event{-1, &a[i]}
	}
	sort.Sort(Events(es))

	ymax, x1, x2 := 0, 0, 0
	t := NewSegTree(len(xx))
	for _, e := range es {
//		fmt.Println(e.t, e.Worker)
		l := xid(e.l)
		r := xid(e.v)+1
		t.Inc(l, r, e.t)
//		fmt.Println(t.Max())
		if x, y := t.Max(); y > ymax {
			ymax = y
			x1 = xx[x]
			x2 = e.v
		}
	}
//	fmt.Println(ymax, x1, x2)

	ls := []int{}
	for i := range a {
		if a[i].l <= x1 && x1 <= a[i].v && x2 <= a[i].r {
			ls = append(ls, a[i].i+1)
		}
	}
	pretty := fmt.Sprint(ls)
	fmt.Println(ymax)
	fmt.Println(pretty[1:len(pretty)-1])
}


// 165C
package main

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

func main() {
	var a string
	var arr [1000005]int64
	var k, i int
	j := 0
	var ans int64
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &k, &a)
	arr[0] = 1
	for i = 0; i < int(len(a)); i++ {
		if a[i] == '1' {
			j++
		}
		if j >= k {
			ans += arr[j-k]
		}
		arr[j]++
	}
	fmt.Fprint(out, ans)
	out.Flush()
}

//http://codeforces.com/problemset/problem/165/C
//C. Another Problem on Strings

package main

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

func main() {
	var (
		k, i, s, lseq int32 // small,big
		seq           string
		ans           int64
		sum           []int32
	)

	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &k)
	fmt.Fscan(in, &seq)
	lseq = int32(len(seq))
	//fmt.Println(k, seq, lseq)

	if k > lseq {
		goto OK
	}
	sum = make([]int32, lseq+1, lseq+1)
	sum[0] = 1
	for i = 0; i < lseq; i++ {
		if seq[i] == '1' {
			s++
		}
		if s >= k {
			ans += int64(sum[s-k])
		}
		sum[s]++
	}
	//sum = sum[:s+1]
	//fmt.Println(sum)

OK:
	fmt.Println(ans)
}

// Author: sighduck
// URL: https://codeforces.com/contest/165/problem/C

package main

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

func Solve(n int, s string) int64 {
	count := make([]int, len(s)+1)
	count[0] = 1
	prefix := 0
	ans := int64(0)
	for _, elem := range s {
		if elem == '1' {
			prefix += 1
		}
		if prefix >= n {
			ans += int64(count[prefix-n])
		}
		count[prefix] += 1
	}
	return ans
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)

	fmt.Fprintf(writer, "%d\n", Solve(n, s))
}

// 165C-mic
package main

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

func main() {
	//z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewReader(os.Stdin)
	var n int
	var ans int64
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	//s, _ = inp.ReadString('\n')
	fmt.Fscan(inp, &s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += int64(dp[sum-n])
		}
		dp[sum]++
	}
	fmt.Println(ans)
}

// 165C-mic
package main

import (
	"fmt"
	"math"
)

func main() {
	var k, a, b, res, c int64
	var str string
	var m1 [1000000]int64
	fmt.Scan(&k, &str)
	i := len(str) - 1
	for ; i >= 0; i-- {
		if str[i] == '1' {
			m1[i] = 0
			b = 0
		} else {
			m1[i] = b + 1
		}
	}
	for i := 0; i < len(str); i++ {
		if str[i] == '1' {
			c++
		}
		for c > k {
			if str[a] == '1' {
				c--
			}
			a++
		}
		if c == k {
			res += int64(math.Min(float64(m1[a]), float64(i)-float64(a))) + int64(1)
		}
	}
	fmt.Println(res)
}

// 165C-mic
package main

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

func main() {
	z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewScanner(os.Stdin)
	var n int
	ans := int64(0)
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	inp.Scan()
	s = inp.Text()
	//fmt.Scan(&s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += int64(dp[sum-n])
		}
		dp[sum]++
	}
	z.WriteString(strconv.FormatInt(ans, 32) + "\n")
	z.Flush()
}

// 165C-mic
package main

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

func main() {
	z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewReader(os.Stdin)
	var n int
	ans := 0
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	s, _ = inp.ReadString('\n')
	//fmt.Scan(&s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += dp[sum-n]
		}
		dp[sum]++
	}
	z.WriteString(strconv.Itoa(ans))
	z.Flush()
}

// 165C-mic
package main

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

func main() {
	//z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewReader(os.Stdin)
	var n int
	ans := 0
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	//s, _ = inp.ReadString('\n')
	fmt.Fscan(inp, &s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += dp[sum-n]
		}
		dp[sum]++
	}
	fmt.Println(ans)
}

// 165C-mic
package main

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

func main() {
	//z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewReader(os.Stdin)
	var n int
	ans := 0
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	s, _ = inp.ReadString('\n')
	//fmt.Scan(&s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += dp[sum-n]
		}
		dp[sum]++
	}
	fmt.Println(ans)
}

// 165C-mic
package main

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

func main() {
	z := bufio.NewWriter(os.Stdout)
	inp := bufio.NewScanner(os.Stdin)
	var n int
	ans := 0
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	inp.Scan()
	s = inp.Text()
	//fmt.Scan(&s)
	var i int
	l := len(s)
	sum := 0
	dp[0] = 1
	for i = 0; i < l; i++ {
		if s[i] == '1' {
			sum++
		}
		if sum-n >= 0 {
			ans += dp[sum-n]
		}
		dp[sum]++
	}
	z.WriteString(strconv.Itoa(ans) + "\n")
	z.Flush()
}

// 165C-mic
package main

import (
	"fmt"
)

func main() {
	var n int
	var dp [1000005]int
	var s string
	fmt.Scan(&n)
	for j := 0; j < n; j++ {
		fmt.Scan(&s)
		var i int
		l := len(s)
		sum := 0
		dp[0] = 1
		ans := int64(0)
		for i = 0; i < l; i++ {
			if s[i] == '1' {
				sum++
			}
			if sum-n >= 0 {
				ans += int64(dp[sum-n])
				dp[sum]++
			}
		}
		fmt.Println(ans)
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/165/problem/C

package main

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

func Solve(n int, s string) int {
	count := make([]int, len(s)+1)
	count[0] = 1
	prefix := 0
	ans := 0
	for _, elem := range s {
		if elem == '1' {
			prefix += 1
		}
		if prefix >= n {
			ans += count[prefix-n]
		}
		count[prefix] += 1
	}
	return ans
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)

	fmt.Fprintf(writer, "%d\n", Solve(n, s))
}