A sequence of $$$n$$$ numbers is called a permutation if it contains all integers from $$$1$$$ to $$$n$$$ exactly once. For example, the sequences [$$$3, 1, 4, 2$$$], [$$$1$$$] and [$$$2,1$$$] are permutations, but [$$$1,2,1$$$], [$$$0,1$$$] and [$$$1,3,4$$$] — are not.Polycarp lost his favorite permutation and found only some of its elements — the numbers $$$b_1, b_2, \dots b_m$$$. He is sure that the sum of the lost elements equals $$$s$$$.Determine whether one or more numbers can be appended to the given sequence $$$b_1, b_2, \dots b_m$$$ such that the sum of the added numbers equals $$$s$$$, and the resulting new array is a permutation?

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) —the number of test cases.  Then the descriptions of the test cases follow. The first line of each test set contains two integers $$$m$$$ and $$$s$$$ ($$$1 \le m \le 50$$$, $$$1 \le s \le 1000$$$)—-the number of found elements and the sum of forgotten numbers. The second line of each test set contains $$$m$$$ different integers $$$b_1, b_2 \dots b_m$$$ ($$$1 \le b_i \le 50$$$) — the elements Polycarp managed to find.

Print $$$t$$$ lines, each of which is the answer to the corresponding test set. Print as the answer YES if you can append several elements to the array $$$b$$$, that their sum equals $$$s$$$ and the result will be a permutation. Output NO otherwise. You can output the answer in any case (for example, yEs, yes, Yes and YES will be recognized as positive answer).

NoteIn the test case of the example, $$$m=3, s=13, b=[3,1,4]$$$. You can append to $$$b$$$ the numbers $$$6,2,5$$$, the sum of which is $$$6+2+5=13$$$. Note that the final array will become $$$[3,1,4,6,2,5]$$$, which is a permutation.In the second test case of the example, $$$m=1, s=1, b=[1]$$$. You cannot append one or more numbers to $$$[1]$$$ such that their sum equals $$$1$$$ and the result is a permutation.In the third test case of the example, $$$m=3, s=3, b=[1,4,2]$$$. You can append the number $$$3$$$ to $$$b$$$. Note that the resulting array will be $$$[1,4,2,3]$$$, which is a permutation.

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scan(&m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < m+1; j++ {
			var cur int
			fmt.Scan(&cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0

		for j := 1; j < m+1; j++ {
			sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Print("NO\n")

		} else if sum == s {
			// equal s
			fmt.Print("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Print("YES\n")
			} else {
				fmt.Print("NO\n")
			}
		}
	}
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums map[int]bool

func lostPermutation() {
	var tc int
	for fmt.Scan(&tc); tc > 0; tc-- {
		var count, target, max, n int
		nums = make(map[int]bool)
		fmt.Scan(&count, &target)
		for ; count > 0; count-- {
			fmt.Scan(&n)
			nums[n] = true
			if max < n {
				max = n
			}
		}

		var sum int
		i := 1
		for sum < target {
			if !nums[i] {
				sum += i
				nums[i] = true
			}
			i++
		}

		if sum == target && len(nums) >= max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		b := make([]bool, 68)

		var m, s, mb int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			var temp int
			fmt.Fscan(r, &temp)
			b[temp] = true
			if temp > mb {
				mb = temp
			}
		}

		var rsum int
		res := "NO"
		for i, v := range b {
			if !v {
				rsum += i
			}
			if rsum == s && i >= mb {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

func bsearch(l, r, v int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if m*(m+1) > 2*v { return bsearch(l, m-1, v) }
	return bsearch(m, r, v)
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var m, s, b, mb, n int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			fmt.Fscan(r, &b)
			s += b
			if b > mb {
				mb = b
			}
		}

		n = bsearch(1, 67, s)
		res := "YES"
		if n*(n+1) != 2*s || n < mb {
			res = "NO"
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var m, s, mb, rsum int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			var temp int
			fmt.Fscan(r, &temp)
			rsum -= temp
			if temp > mb {
				mb = temp
			}
		}

		rsum += (mb*(mb+1)) / 2
		for rsum < s {
			mb++
			rsum += mb
		}

		res := "YES"
		if rsum > s {
			res = "NO"
		}
		fmt.Fprintln(w, res)
	}

}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		b := make([]bool, 1001)

		var m, s, mb int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			var temp int
			fmt.Fscan(r, &temp)
			b[temp] = true
			if temp > mb {
				mb = temp
			}
		}

		var rsum int
		res := "NO"
		for i, v := range b {
			if !v {
				rsum += i
			}
			if rsum == s && i >= mb {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var used = make([]bool, 101)
	var s2 int
	for i := 0; i < n; i++ {
		used[b[i]] = true
		s2 += b[i]
	}

	var s int
	for i := 1; i <= 100; i++ {
		if s == s1 && n == 0 {
			fmt.Fprintln(writer, "YES")
			return
		}
		if !used[i] {
			s += i
		} else {
			n--
		}
	}

	fmt.Fprintln(writer, "NO")
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))

	solve1759B()
}

func solve1759B() {
	n := readInt()

	// inputArrs := []string{}

	for i := 0; i < n; i++ {
		preDefinedArr := make([]int, 101)
		solveEach1759B(preDefinedArr)
	}
}

func solveEach1759B(arr []int) {
	input := readInts()

	m := input[0]
	s := input[1]
	inputArr := readInts()
	// fmt.Println(m, s, inputArr)
	maxNumb := -1
	for i := 0; i < m; i++ {
		arr[inputArr[i]] += 1
		if inputArr[i] > maxNumb {
			maxNumb = inputArr[i]
		}
	}

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			s -= i
			arr[i] += 1
			// fmt.Println("i = ", i)
			if maxNumb < i {
				maxNumb = i
			}
		}
		// fmt.Println("s = ", s)
		if s <= 0 {
			break
		}
	}
	for i := 1; i <= maxNumb; i++ {
		if arr[i] == 0 {
			fmt.Println("NO")
			return
		}
	}
	if s < 0 || s > 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import . "fmt"
import "bufio"
import "os"

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

const Lim = 100

func ans() {
	var m int
	var s int
	Fscan(in, &m, &s)
	var b []int = make([]int, m)
	for i := 0; i < m; i++ {
		Fscan(in, &b[i])
	}
	var bSet map[int]bool = make(map[int]bool)
	for i := 0; i < m; i++ {
		bSet[b[i]] = true
	}
	for i := 1; i <= Lim; i++ {
		if bSet[i] {
			m--
		} else {
			s -= i
		}
		if s == 0 && m == 0 {
			Fprintln(out, "YES")
			return
		}
		if s < 0 {
			Fprintln(out, "NO")
			return
		}
	}
}

func main() {
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

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

func main() {
	var (
		t int
		s int
	)
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < t; i++ {
		scanner.Scan()
		tsl := strings.Split(scanner.Text(), " ")
		s, _ = strconv.Atoi(tsl[1])
		scanner.Scan()
		bs := strings.Split(scanner.Text(), " ")
		var b []int
		for j := 0; j < len(bs); j++ {
			x, _ := strconv.Atoi(bs[j])
			b = append(b, x)
		}
		for j := 1; s > 0; j++ {
			c := Contains(b, j)
			if !c {
				s -= j
				b = append(b, j)
			}
		}
		sort.Ints(b)
		if s == 0 && Check(b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func Contains(sl []int, s int) bool {
	for _, a := range sl {
		if a == s {
			return true
		}
	}
	return false
}

func Check(sl []int) bool {
	for i := 0; i < len(sl); i++ {
		if sl[i] != i+1 {
			return false
		}
	}
	return true
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newStdIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}
func solve(io *IO) {
	m := io.ScanInt32()
	s := io.ScanInt32()
	el := make([]int32, 0, m)
	max := int32(0)
	sum := int32(0)
	for i := int32(0); i < m; i++ {
		el = append(el, io.ScanInt32())
		if el[i] > max {
			max = el[i]
		}
		sum -= int32(el[i])
	}
	sum += (int32(max) + 1) * (int32(max)) / 2

	if sum == s {
		io.PrintLn("YES")
		return
	}
	max++
	for sum < s {
		sum += int32(max)

		if sum == s {
			io.PrintLn("YES")
			return
		}
		max++
	}
	io.PrintLn("NO")
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion

package main

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

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

func (in *CF1759B) 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 *CF1759B) load() {
  if len(in.split) <= in.index {
    in.split = strings.Split(in.GetLine(), in.separator)
    in.index = 0
  }
}

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

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

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

/**
Run solve the problem CF1759B
Date: 11/20/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1759/B
Problem: CF1759B
**/
func (in *CF1759B) Run() {
  for t := in.NextInt(); t > 0; t-- {
    m, s := in.NextInt(), in.NextInt()
    mapa := make(map[int]bool)
    max := 0
    for i := 0; i < m; i++ {
      val := in.NextInt()
      mapa[val] = true
      if max < val {
        max = val
      }
    }
    sum := 0
    for i := 1; i < max; i++ {
      if _, e := mapa[i]; !e {
        sum += i
      }
    }
    for sum < s {
      sum += max + 1
      max++
    }

    if sum == s {
      fmt.Println("YES")
    } else {
      fmt.Println("NO")
    }

  }
}

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

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

package main

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

func Contains(slice []int, n int) bool {
	for _, v := range slice {
		if v == n {
			return true
		}
	}
	return false
}

func IsValid(s int, used []int) bool {
	// fmt.Println(s, used)
	if s == 0 {
		return true
	}

	if s < 0 {
		return false
	}

	for i := 1; i <= s; i++ {
		if Contains(used, i) {
			continue
		}

		isValid := IsValid(s-i, append(used, i))
		if isValid {
			return true
		} else {
			return false
		}
	}

	return false
}

func AdjustToPerm(arr []int) ([]int, int) {
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}

	s := 0
	perm := make([]int, max)
	for i := 1; i <= max; i++ {
		perm[i-1] = i
		if !Contains(arr, i) {
			s += i
		}
	}

	return perm, s
}

func main() {
	// file, _ := os.Open("input_B.txt")
	// defer file.Close()

	// scanner := bufio.NewScanner(file)
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	for i := 0; i < n; i++ {
		scanner.Scan()
		s, _ := strconv.Atoi(strings.Split(scanner.Text(), " ")[1])

		scanner.Scan()
		line := strings.Split(scanner.Text(), " ")
		used := make([]int, len(line))
		for j, val := range line {
			used[j], _ = strconv.Atoi(val)
		}

		perm, ds := AdjustToPerm(used)
		// fmt.Println(s-ds, perm)
		if IsValid(s-ds, perm) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		var m, s int
		fmt.Fscan(in, &m, &s)
		arr := make([]int, m)
		for i := 0; i < m; i++ {
			fmt.Fscan(in, &arr[i])
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		pre, curS := 1, 0
		for i := 0; i < m; i++ {
			if arr[i] == pre {
				pre++
				continue
			}
			tmpS := (arr[i] - 1 + pre) * (arr[i] - pre) / 2
			curS += tmpS
			pre = arr[i] + 1
		}
		mx := arr[m-1] + 1
		for curS < s {
			curS += mx
			mx++
		}
		if curS == s {
			fmt.Fprint(out, "YES\n")
		} else {
			fmt.Fprint(out, "NO\n")
		}
	}
	out.Flush()
}

package main

import "fmt"

func main() {
	var t, m, s, x, max int
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&m, &s)
		set := make(map[int]int)
		max = 0
		for i := 0; i < m; i++ {
			fmt.Scan(&x)
			set[x]++
			if x > max {
				max = x
			}
		}
		//fmt.Println(set)
		var r, c int
		c = 1
		for r < s {
			if !(set[c] > 0) {
				r += c
				//fmt.Println("r=>", r, "c => ", c)
				set[c]++
			}
			c++
		}
		if r == s && len(set) >= max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func solve(in io.Reader, out io.Writer) {
	var n int
	var x int
	var s int
	var mav int
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &s)
	maps := map[int]bool{}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &x)
		maps[x] = true
		mav = max(mav, x)
	}
	var ok bool = true
	for i := 1; i <= mav; i++ {
		if !maps[i] {
			s -= i
			if s < 0 {
				ok = false
			}
		}
	}
	if !ok {
		fmt.Println("NO")
	} else {
		// s > 0
		// s == 0
		if s == 0 {
			fmt.Println("YES")
		} else {
			curr := mav + 1
			for {
				s -= curr
				if s < 0 {
					ok = false
					break
				} else if s == 0 {
					break
				}
				curr += 1
			}
			// fmt.Println(curr)
			if ok {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func main() {
	var t int
	fmt.Fscan(os.Stdin, &t)
	for i := 0; i < t; i++ {
		solve(os.Stdin, os.Stdout)
	}
}

package main

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

func Solve(reader *bufio.Reader, writer *bufio.Writer) {
	var m, s, curSum int
	fmt.Fscan(reader, &m, &s)
	mx := 0
	for i := 0; i < m; i++ {
		var cur int
		fmt.Fscan(reader, &cur)
		curSum += cur
		if cur > mx {
			mx = cur
		}
	}
	sumNeed := (mx + 1) * mx / 2
	between := sumNeed - curSum
	s -= between
	for s > 0 {
		mx++
		s -= mx
	}

	if s == 0 {
		fmt.Fprintf(writer, "YES\n")
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
}

func main() {
	var reader *bufio.Reader
	var writer *bufio.Writer

	filename_in := "data.in"
	filename_out := "data.out"

	stdinout := true
	readtests := true
	tests := 1

	if (!stdinout || inArgs("local")) && !inArgs("std") {
		infile, inerr := os.Open(filename_in)
		if inerr != nil {
			if os.IsNotExist(inerr) {
				os.Create(filename_in)
			}
			fmt.Println(inerr)
			return
		}
		defer infile.Close()

		outfile, outerr := os.OpenFile(filename_out, os.O_WRONLY, os.ModeAppend)
		if outerr != nil {
			if os.IsNotExist(outerr) {
				outfile, outerr = os.Create(filename_out)
				if outerr != nil {
					fmt.Println(outerr)
					return
				}
			}
		}
		defer outfile.Close()

		reader = bufio.NewReader(infile)
		writer = bufio.NewWriter(outfile)
	} else if stdinout || inArgs("std") {
		reader = bufio.NewReader(os.Stdin)
		writer = bufio.NewWriter(os.Stdout)
	}
	defer func() {
		err := writer.Flush()
		if err != nil {
			fmt.Println(err)
		}
	}()

	if readtests || inArgs("local") {
		fmt.Fscanf(reader, "%d\n", &tests)
	}

	for i := 0; i < tests; i++ {
		Solve(reader, writer)
		fmt.Fscanf(reader, "\n")
	}

}

func inArgs(arg string) bool {
	for _, a := range os.Args {
		if a == arg {
			return true
		}
	}
	return false
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < m+1; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0

		if t == 3 {
			fmt.Printf("beforeLoop%d|", m+1)
		}

		for j := 1; j < m+1; j++ {
			if t == 3 {
				fmt.Printf("j[%d]|", j)
			}

			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k

				if t == 3 {
					fmt.Printf("k[%d]|", k)
				}
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Print("\n")
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < m+1; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < m+1; j++ {
			if t == 3 {
				fmt.Printf("j[%d]|", j)
			}

			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k

				if t == 3 {
					fmt.Printf("k[%d]|", k)
				}
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Print("\n")
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < len(l); j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			if t == 3 {
				fmt.Printf("j[%d]|", j)
			}

			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k

				if t == 3 {
					fmt.Printf("k[%d]|", k)
				}
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Print("\n")
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < len(l); j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k

				if t == 3 {
					fmt.Printf("%d_", k)
				}
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Print("\n")
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < len(l); j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Printf("%d\n", sum)
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < len(l); j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Printf("%d\n", sum)
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m+1)
		l[0] = 0
		for j := 1; j < len(l); j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < m; j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if t == 3 {
			fmt.Printf("%d", sum)
			continue
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[m-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < m; j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if tt == 3 {
			fmt.Printf("%d", sum)
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[m-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < m; j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[m-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			for k := l[j-1] + 1; k < l[j]; k++ {
				sum += k
			}
			// sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		var sum int = 0
		for j := 1; j < len(l); j++ {
			sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
		fmt.Printf("\n")
	}
}

package main

import (
	"fmt"
	"sort"
)

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

	for t := 0; t < tt; t++ {
		var m, s int
		fmt.Scanf("%d %d", &m, &s)

		// parse array
		l := make([]int, m)
		for j := 0; j < m; j++ {
			var cur int
			fmt.Scanf("%d", &cur)
			l[j] = cur
		}
		sort.Ints(l)

		// compute sum of missing elements
		sum := 0
		for j := 1; j < len(l); j++ {
			sum += ((l[j] - l[j-1] - 1) * (l[j] + l[j-1])) / 2
		}

		if sum > s {
			// above s
			fmt.Printf("NO\n")

		} else if sum == s {
			// equal s
			fmt.Printf("YES\n")

		} else {
			// bellow s
			k := l[len(l)-1] + 1
			for sum < s {
				sum += k
				k++
			}
			if sum == s {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [10000]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var lsum, rsum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &lsum)
		nums = [10000]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			rsum += n
		}

		targetSum := lsum + rsum
		var sum int
		var i int
		for i = 1; i < len(nums) && sum < targetSum; i++ {
			sum += i
			nums[i] = 1
		}
		if sum == targetSum {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [10000]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var lsum, rsum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &lsum)
		nums = [10000]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			rsum += n
		}

		targetSum := lsum + rsum
		var sum int
		var i int
		for i = 1; i < len(nums) && sum < targetSum; i++ {
			sum += i
			nums[i] = 1
		}
		fmt.Println(nums, i)
		if sum == targetSum {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [1000]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var lsum, rsum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &lsum)
		nums = [1000]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			rsum += n
		}

		targetSum := lsum + rsum
		var sum int
		for i := 1; i < len(nums) && sum < targetSum; i++ {
			sum += i
		}
		if sum == targetSum {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [52]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var lsum, rsum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &lsum)
		nums = [52]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			rsum += n
		}

		targetSum := lsum + rsum
		var sum int
		for i := 1; i < len(nums) && sum < targetSum; i++ {
			sum += i
		}
		if sum == targetSum {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
		continue

		for i := 1; i < len(nums) && sum < targetSum; i++ {
			if nums[i] == 0 {
				sum += i
				nums[i] = 1
			}
		}

		print := "YES"
		if sum == targetSum {
			haveZero := false
			for i := 1; i < len(nums); i++ {
				if nums[i] == 0 {
					haveZero = true
				}
				if nums[i] == 1 && haveZero {
					print = "NO"
					break
				}
			}
		} else {
			print = "NO"
		}
		fmt.Println(print)
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [52]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var targetSum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &targetSum)
		nums = [52]int{}
		exit := false
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			if n == 0 || nums[n] == 1 {
				exit = true
				break
			}
			nums[n] = 1
		}
		if exit {
			fmt.Println("NO")
			continue
		}

		var sum int
		for i := 1; i < len(nums) && sum < targetSum; i++ {
			if nums[i] == 0 {
				sum += i
				nums[i] = 1
			}
		}

		print := "YES"
		if sum == targetSum {
			haveZero := false
			for i := 1; i < len(nums); i++ {
				if nums[i] == 0 {
					haveZero = true
				}
				if nums[i] == 1 && haveZero {
					print = "NO"
					break
				}
			}
		} else {
			print = "NO"
		}
		fmt.Println(print)
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [51]int

/*
3 1
2 2 4

2 3 4

*/
func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var targetSum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &targetSum)
		nums = [51]int{}
		exit := false
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			if n == 0 || nums[n] == 1 {
				exit = true
				break
			}
			nums[n] = 1
		}
		if exit {
			fmt.Println("NO")
			continue
		}

		var sum int
		for i := 1; i < len(nums) && sum < targetSum; i++ {
			if nums[i] == 0 {
				sum += i
				nums[i] = 1
			}
		}

		print := "YES"
		if sum == targetSum {
			haveZero := false
			for i := 1; i < len(nums); i++ {
				if nums[i] == 0 {
					haveZero = true
				}
				if nums[i] == 1 && haveZero {
					print = "NO"
					break
				}
			}
		} else {
			print = "NO"
		}
		fmt.Println(print)
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [50]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var targetSum int
		var maxNum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &targetSum)
		nums = [50]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			if maxNum < n {
				maxNum = n
			}
		}

		var sum int
		var i int
		isPermutation := true
		prevI := 1
		for i = 1; i < len(nums) && sum < targetSum; i++ {
			if nums[i] == 0 {
				prevI = i
				sum += i
			}
			if prevI != i-1 {
				isPermutation = false
			}
		}

		if sum == targetSum && i >= maxNum && !isPermutation {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func main() {
	//yes()
	lostPermutation()
}

var nums [50]int

func lostPermutation() {
	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var count int
		var targetSum int
		var maxNum int
		fmt.Fscan(r, &count)
		fmt.Fscan(r, &targetSum)
		nums = [50]int{}
		for ; count > 0; count-- {
			var n int
			fmt.Fscan(r, &n)
			nums[n] = 1
			if maxNum < n {
				maxNum = n
			}
		}

		var sum int
		var i int
		for i = 1; i < len(nums) && sum < targetSum; i++ {
			if nums[i] == 0 {
				sum += i
			}
		}

		if sum == targetSum && i >= maxNum {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

const Yes = "Yes"

var YesByte = []byte(Yes)
var start = map[byte]int{
	'Y': 0,
	'e': 1,
	's': 2,
}

func yes() {

	r := bufio.NewReader(os.Stdin)
	var tc int
	for fmt.Fscan(r, &tc); tc > 0; tc-- {
		var s string
		fmt.Fscan(r, &s)
		sbyte := []byte(s)
		saidYes(sbyte)
	}
}

func saidYes(sbyte []byte) {
	var yesIdx int
	var exists bool
	if yesIdx, exists = start[sbyte[0]]; !exists {
		fmt.Println("NO")
		return
	}

	for i := 0; i < len(sbyte); i, yesIdx = i+1, yesIdx+1 {
		if YesByte[yesIdx%3] != sbyte[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

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

func bsearch(l, r, v int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if m*(m+1) > 2*v { return bsearch(l, m-1, v) }
	return bsearch(m, r, v)
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var m, s, b, mb, n int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			fmt.Fscan(r, &b)
			s += b
			if b > mb {
				mb = b
			}
		}

		n = bsearch(1, 67, s)
		res := "YES"
		if n*(n+1) != 2*s || n < mb || n > 50 {
			res = "NO"
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		b := make([]bool, 61)

		var m, s, mb int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			var temp int
			fmt.Fscan(r, &temp)
			b[temp] = true
			if temp > mb {
				mb = temp
			}
		}

		var rsum int
		res := "NO"
		for i, v := range b {
			if !v {
				rsum += i
			}
			if rsum == s && i >= mb {
				res = "YES"
				break
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

func bsearch(l, r, v int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if m*(m+1) > 2*v { return bsearch(l, m-1, v) }
	return bsearch(m, r, v)
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var m, s, b, mb, n int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			fmt.Fscan(r, &b)
			s += b
			if b > mb {
				mb = b
			}
		}

		n = bsearch(1, 50, s)
		res := "YES"
		if n*(n+1) != 2*s || n < mb || n > 50 {
			res = "NO"
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

func bsearch(l, r, v int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if m*(m+1) > 2*v { return bsearch(l, m-1, v) }
	return bsearch(m, r, v)
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var m, s, b, mb, n int
		fmt.Fscan(r, &m, &s)

		for i := 0; i < m; i++ {
			fmt.Fscan(r, &b)
			s += b
			if b > mb {
				mb = b
			}
		}

		n = bsearch(1, 50, s)
		res := "YES"
		if n*(n+1) != 2*s || n < mb {
			res = "NO"
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var s2 int
	for i := 0; i < n; i++ {
		s2 += b[i]
	}

	var s int
	for i := 1; i <= 10000; i++ {
		if s-s2 == s1 {
			fmt.Fprintln(writer, "YES")
			return
		}
		s += i
	}

	fmt.Fprintln(writer, "NO")
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var s2 int
	for i := 0; i < n; i++ {
		s2 += b[i]
	}

	var s int
	for i := 1; i <= 1000; i++ {
		if s-s2 == s1 {
			fmt.Fprintln(writer, "YES")
			return
		}
		s += i
	}

	fmt.Fprintln(writer, "NO")
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var s = s1
	for i := 0; i < n; i++ {
		s += b[i]
	}

	t := float64(1 + 8*s)
	x := math.Sqrt(t)
	if math.Abs(t-x*x) <= 1e-6 && int(x-1)%2 == 0 {
		m := int(x-1) / 2
		for i := 0; i < n; i++ {
			if b[i] >= 1 && b[i] <= m {
				continue
			} else {
				fmt.Fprintln(writer, "NO")
				return
			}
		}
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var s = s1
	for i := 0; i < n; i++ {
		s += b[i]
	}

	t := float64(1 + 8*s)
	x := math.Sqrt(t)
	if math.Abs(t-x*x) <= 1e-6 && int(x-1)%2 == 0 {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n, s1 := readTwoInt(reader)
	b := readArrayInt(reader)

	var s = s1
	for i := 0; i < n; i++ {
		s += b[i]
	}

	x := math.Sqrt(float64(1 + 8*s))
	if x*x == float64(1+8*s) && int(x-1)%2 == 0 {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))

	solve1759B()
}

func solve1759B() {
	n := readInt()

	// inputArrs := []string{}

	for i := 0; i < n; i++ {
		preDefinedArr := make([]int, 101)
		solveEach1759B(preDefinedArr)
	}
}

func solveEach1759B(arr []int) {
	input := readInts()

	m := input[0]
	s := input[1]
	inputArr := readInts()
	// fmt.Println(m, s, inputArr)
	maxNumb := -1
	for i := 0; i < m; i++ {
		arr[inputArr[i]] += 1
		if inputArr[i] > maxNumb {
			maxNumb = inputArr[i]
		}
	}

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			s -= i
			arr[i] += 1
			fmt.Println("i = ", i)
			if maxNumb < i {
				maxNumb = i
			}
		}
		fmt.Println("s = ", s)
		if s <= 0 {
			break
		}
	}
	for i := 1; i <= maxNumb; i++ {
		if arr[i] == 0 {
			fmt.Println("NO")
			return
		}
	}
	if s < 0 || s > 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))

	solve1759B()
}

func solve1759B() {
	n := readInt()

	// inputArrs := []string{}

	for i := 0; i < n; i++ {
		preDefinedArr := make([]int, 51)
		solveEach1759B(preDefinedArr)
	}
}

func solveEach1759B(arr []int) {
	input := readInts()

	m := input[0]
	s := input[1]
	inputArr := readInts()
	// fmt.Println(m, s, inputArr)
	maxNumb := -1
	for i := 0; i < m; i++ {
		arr[inputArr[i]] += 1
		if inputArr[i] > maxNumb {
			maxNumb = inputArr[i]
		}
	}

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			s -= i
			arr[i] += 1
			if maxNumb < i {
				maxNumb = i
			}
		}
		if s <= 0 {
			break
		}
	}
	for i := 1; i <= maxNumb; i++ {
		if arr[i] == 0 {
			fmt.Println("NO")
			return
		}
	}
	if s < 0 || s > 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))

	solve1759B()
}

func solve1759B() {
	n := readInt()

	// inputArrs := []string{}
	preDefinedArr := make([]int, 51)

	for i := 0; i < n; i++ {
		solveEach1759B(preDefinedArr)
	}
}

func solveEach1759B(arr []int) {
	input := readInts()

	m := input[0]
	s := input[1]
	inputArr := readInts()

	maxNumb := -1
	for i := 0; i < m; i++ {
		arr[inputArr[i]] += 1
		if inputArr[i] > maxNumb {
			maxNumb = inputArr[i]
		}
	}

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			s -= i
			arr[i] += 1
			if maxNumb < i {
				maxNumb = i
			}
		}
		if s <= 0 {
			break
		}
	}
	for i := 1; i <= maxNumb; i++ {
		if arr[i] == 0 {
			fmt.Println("NO")
			return
		}
	}
	if s < 0 || s > 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))

	solve1759B()
}

func solve1759B() {
	n := readInt()

	// inputArrs := []string{}
	preDefinedArr := make([]int, 51)

	for i := 0; i < n; i++ {
		solveEach1759B(preDefinedArr)
	}
}

func solveEach1759B(arr []int) {
	input := readInts()

	m := input[0]
	s := input[1]
	inputArr := readInts()

	for i := 0; i < m; i++ {
		arr[inputArr[i]] += 1
	}

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 && (s-i) >= 0 {
			s -= i
			arr[i] += 1
		}
		// fmt.Println(arr)
		// fmt.Println(s)
		if s <= 0 {
			break
		}
	}
	if s < 0 || s > 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import . "fmt"
import "bufio"
import "os"

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

const Lim = 100
var sums map[int]bool = make(map[int]bool)
var flag bool = false

func preCal() {
	for i := 1; i <= Lim; i++ {
		var sum int = i * (i + 1) / 2
		sums[sum] = true
	}
}

func ans(cur int) {
	var m int
	var s int
	Fscan(in, &m, &s)
	var b []int = make([]int, m)
	for i := 0; i < m; i++ {
		Fscan(in, &b[i])
	}
	if flag && cur == 10 {
		Fprintln(out, "m:", m)
		Fprintln(out, "s:", s)
		Fprintln(out, "b:", b)
		return
	}
	if cur == 0 && s == 981 {
		flag = true
	}
	var sum int = s
	for i := 0; i < m; i++ {
		sum += b[i]
	}
	if sums[sum] {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

func main() {
	defer out.Flush()
	preCal()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans(i)
	}
}

package main

import . "fmt"
import "bufio"
import "os"

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

const Lim = 200
var sums map[int]bool = make(map[int]bool)

func preCal() {
	for i := 1; i <= Lim; i++ {
		var sum int = i * (i + 1) / 2
		sums[sum] = true
	}
}

func ans() {
	var m int
	var s int
	Fscan(in, &m, &s)
	var b []int = make([]int, m)
	for i := 0; i < m; i++ {
		Fscan(in, &b[i])
	}
	var sum int = s
	for i := 0; i < m; i++ {
		sum += b[i]
	}
	if sums[sum] {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

func main() {
	defer out.Flush()
	preCal()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

import . "fmt"
import "bufio"
import "os"

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

const Lim = 100
var sums map[int]bool = make(map[int]bool)

func preCal() {
	for i := 1; i <= Lim; i++ {
		var sum int = i * (i + 1) / 2
		sums[sum] = true
	}
}

func ans() {
	var m int
	var s int
	Fscan(in, &m, &s)
	var b []int = make([]int, m)
	for i := 0; i < m; i++ {
		Fscan(in, &b[i])
	}
	var sum int = s
	for i := 0; i < m; i++ {
		sum += b[i]
	}
	if sums[sum] {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

func main() {
	defer out.Flush()
	preCal()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

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

func main() {
	var (
		t int
		s int
	)
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < t; i++ {
		scanner.Scan()
		tsl := strings.Split(scanner.Text(), " ")
		s, _ = strconv.Atoi(tsl[1])
		scanner.Scan()
		b := strings.Split(scanner.Text(), " ")
		for j := 1; s > 0; j++ {
			x := strconv.Itoa(j)
			c := Contains(b, x)
			if !c {
				s -= j
				b = append(b, x)
			}
		}
		sort.Strings(b)
		if s == 0 && Check(b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func Contains(sl []string, s string) bool {
	for _, a := range sl {
		if a == s {
			return true
		}
	}
	return false
}

func Check(sl []string) bool {
	c := 0
	for i := 0; i < len(sl); i++ {
		x := strconv.Itoa(i + 1)
		if sl[i] == x {
			c++
		}
	}
	if c == len(sl) {
		return true
	}
	return false
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newFileIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}
func solve(io *IO) {
	m := io.ScanInt32()
	s := io.ScanInt32()
	el := make([]int32, 0, m)
	max := int32(0)
	sum := int32(0)
	for i := int32(0); i < m; i++ {
		el = append(el, io.ScanInt32())
		if el[i] > max {
			max = el[i]
		}
		sum -= int32(el[i])
	}
	sum += (int32(max)+1)*(int32(max)) / 2

	if sum == s {
		io.PrintLn("YES")
		return
	}
	max++
	for sum < s {
		sum += int32(max)

		if sum == s {
			io.PrintLn("YES")
			return
		}
		max++
	}
	io.PrintLn("NO")
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion