package main

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

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

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

// func maxSquare(a int) int {
// 	tmp := int(math.Sqrt(float64(a)))
// 	if tmp*tmp == a {
// 		return tmp * tmp
// 	} else {
// 		return (tmp + 1) * (tmp + 1)
// 	}
// }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var niter int
	fmt.Fscan(in, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var n, k int
		fmt.Fscan(in, &n, &k)
		slc := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &slc[i])
		}
		res := 0
		for i := 0; i < k; i++ {
			if slc[i] > k {
				res++
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "sort"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,x int
		fmt.Fscan(in,&n,&x)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			mapper[j]= list[j]
		}
		sort.Ints(list)
		counter:=0
		for j:=0;j<x;j++{
			if mapper[j] <= list[x-1] {
				continue
			} else {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

var (
	reader bufio.Reader
	writer bufio.Writer
)

func solve() {
	var n, k int
	scan(&n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}

	var ans int = 0
	for i := k; i < n; i++ {
		if a[i] <= k {
			ans++
		}
	}

	printf("%v\n", ans)
}

func main() {
	inp, err := os.Open("in.txt")
	if err == nil {
		os.Stdin = inp
		outp, _ := os.Create("out.txt")
		os.Stdout = outp
		defer outp.Close()
		defer inp.Close()
	}
	reader = *bufio.NewReader(os.Stdin)
	writer = *bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	T = 1
	scan(&T)

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

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(&reader, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(&writer, format, a...)
}

package main

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

var (
	reader bufio.Reader
	writer bufio.Writer
)

func solve() {
	var n, k int
	scan(&n, &k)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}

	var ans = 0
	for i := k; i < n; i++ {
		if a[i] <= k {
			ans++
		}
	}

	printf("%v\n", ans)
}

func main() {
	inp, err := os.Open("in.txt")
	if err == nil {
		os.Stdin = inp
		outp, _ := os.Create("out.txt")
		os.Stdout = outp
		defer outp.Close()
		defer inp.Close()
	}
	reader = *bufio.NewReader(os.Stdin)
	writer = *bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int
	T = 1
	scan(&T)

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

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(&reader, a...)
}

func printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(&writer, format, a...)
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

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

func main() {
	var t, n, k int
	t = readInt()
	for ; t != 0; t-- {
		n, k = readInt2()
		a := readInts(n)
		ans := 0
		for i := 1; i <= k; i++ {
			if a[i-1] <= k {
				ans++
			}
		}
		fmt.Println(k - ans)
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--

		n, k := readTwoNums(reader)
		P := readNNums(reader, n)
		res := solve(k, P)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

func normalize(s string) string {

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

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

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

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

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

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

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

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

	return i
}

func solve(k int, P []int) int {
	// n := len(P)
	// want 1...k
	var res int
	for i := 0; i < k; i++ {
		if P[i] > k {
			res++
		}
	}
	return res
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n, k int
	scan(&n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scan(&a[i])
	}
	count := 0
	for i := 0; i < k; i++ {
		if a[i] <= k {
			count++
		}
	}
	printf("%d\n", k-count)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1712A
Date: 18/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1712/A
Problem: CF1712A
**/
func (in *CF1712A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, k := in.NextInt(), in.NextInt()
		p := make([]int, n)
		mapa := make(map[int]int)
		for i := 0; i < n; i++ {
			p[i] = in.NextInt()
			if i < k {
				mapa[p[i]]++
			}
		}
		sort.Ints(p)
		ans := 0
		for i := 0; i < k; i++ {
			if v, e := mapa[p[i]]; e {
				mapa[p[i]] = v - 1
			} else {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

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

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

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, k int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)
		temp := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &temp[j])
		}
		//fmt.Println("temp: ", temp)
		s, e := 0, n-1
		ans := 0
		for s < k {
			if temp[s] <= k {
				s++
				continue
			}
			if temp[e] > k {
				e--
				continue
			}
			temp[s], temp[e] = temp[e], temp[s]
			ans++
		}
		fmt.Println(ans)
	}
}

package main

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

var bufferedStdin = bufio.NewReader(os.Stdin)
var bufferedStdout = bufio.NewWriter(os.Stdout)

func read(value ...interface{}) {
	_, _ = fmt.Fscan(bufferedStdin, value...)
}

func printf(format string, value ...interface{}) {
	_, _ = fmt.Fprintf(bufferedStdout, format, value...)
}

func printfErr(format string, value ...interface{}) {
	_, _ = fmt.Fprintf(os.Stderr, format, value...)
}

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

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

func findElementIds(array []int, f func(int) bool) []int {
	var result = make([]int, 0)
	for i := 0; i < len(array); i++ {
		if f(array[i]) {
			result = append(result, i)
		}
	}
	return result
}

func reduce(array []int, defaultValue int, f func(int, int) int) int {
	for i := 0; i < len(array); i++ {
		defaultValue = f(defaultValue, array[i])
	}
	return defaultValue
}

func solve(test int) {
	var n, k int
	_, _ = fmt.Fscan(bufferedStdin, &n, &k)
	var ans = 0
	for i := 0; i < n; i++ {
		var a int
		_, _ = fmt.Fscan(bufferedStdin, &a)
		if a > k && i < k {
			ans++
		}
	}
	_, _ = fmt.Fprintf(bufferedStdout, "%d\n", ans)
}

func main() {
	var t = 1
	_, _ = fmt.Fscan(bufferedStdin, &t)
	for i := 0; i < t; i++ {
		solve(i + 1)
	}
	_ = bufferedStdout.Flush()
}

package main

import (
	"fmt"
)

func solve() {
	var n, k int
	fmt.Scan(&n, &k)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	var cnt int
	for i := 0; i < k; i++ {
		if arr[i] > k {
			cnt++
		}
	}
	fmt.Printf("%d\n", cnt)
}

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

}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(in, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}
		mmid := make(map[int]int)
		for i := 0; i < k; i++ {
			mmid[arr[i]] = 1
		}
		var ans int
		for i := 1; i <= k; i++ {
			if _, ok := mmid[i]; !ok {
				ans++
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func Solve(_in io.Reader, _out io.Writer) {
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var t, n, k, ans int
	for Fscan(in, &t); t > 0; t-- {
		ans = 0
		Fscan(in, &n, &k)
		a, b := make([]int, n+1), make([]int, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			b[i] = a[i]
		}
		sort.Ints(b)
		for i := n; i > k; i-- {
			if a[i] <= b[k] { ans++ }
		}
		Fprintln(out, ans)
	}
}

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

package main

import "fmt"

func main() {

	t := 0
	if _, err := fmt.Scan(&t); err != nil {
		return
	}
	for ; t > 0; t-- {
		n, k, ans := 0, 0, 0
		if _, err := fmt.Scan(&n, &k); err != nil {
			return
		}
		for i := 0; i < n; i++ {
			p := 0
			if _, err := fmt.Scan(&p); err != nil {
				return
			}
			if i < k && p > k {
				ans++
			}
		}
		fmt.Println(ans)
	}

}

// 00
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, k int
		fmt.Fscan(reader, &n, &k)
		a := make([]int, n)
		ans := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			if i < k && a[i] > k {
				ans++
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for t := 0; t < T; t++ {
		var n, k int
		fmt.Scan(&n, &k)
		var x int
		ans := 0
		for i := 0; i < n; i++ {
			fmt.Scan(&x)
			if x > k && i+1 <= k {
				ans++
			}
		}
		fmt.Println(ans)
	}

}

package main

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

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

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

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

		var tot int
		for i := 0; i < k; i++ {
			if aa[i] <= k {
				tot++
			}
		}
		fmt.Fprintln(out, k-tot)
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		tmp := readArrInt(input)
		n := tmp[0]
		k := tmp[1]
		arr := readArrInt(input)
		fmt.Println(solve(n, k, arr))
	}
}

func solve(n int, k int, arr []int) int {
	result := 0
	for i := 0; i < k; i++ {
		if arr[i] > k {
			result++
		}
	}
	return result
}

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

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

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

func main() {
	defer out.Flush()

	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		fmt.Fprintln(out, solve())
	}
}

func solve() int {
	var n, k int
	fmt.Fscan(in, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}

	if k == n {
		return 0
	}

	i := 0
	j := k
	res := 0
	for {
		for i < k && a[i] <= k {
			i++
		}
		for j < n && a[j] > k {
			j++
		}
		if i < k && j < n {
			res++
			i++
			j++
		} else {
			break
		}
	}
	return res
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, n)
	ans := 0
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		if i < k && arr[i] > k {
			ans++
		}
	}
	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

func A0() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, k, ans int

		Fscan(in, &n, &k)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		for i := k; i < n; i++ {
			if a[i] <= k {
				ans++
			}
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}
func main() { A0() }

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

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

		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Println(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	seen := make(map[int]bool)
	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}
	sort.Ints(arr)

	count := 0
	for i := 0; i < k; i++ {
		if !seen[arr[i]] {
			count++
		}
	}
	return count
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

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

		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	seen := make(map[int]bool)
	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}
	sort.Ints(arr)

	count := 0
	for i := 0; i < k; i++ {
		if !seen[arr[i]] {
			count++
		}
	}
	return count
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)
	ra := make([]int, t)

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

		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		ra[i] = res
	}
	for _, res := range ra {
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	temp := make([]int, n)
	copy(temp, arr)
	sort.Ints(temp)
	seen := make(map[int]bool)

	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}

	count := 0
	for i := 0; i < k; i++ {
		if !seen[temp[i]] {
			count++
		}
	}
	return count
}

package main

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

func main() {
	wonderfulPermutationRead()
}

func wonderfulPermutationRead() {
	in := bufio.NewReader(os.Stdin)
	var t int

	fmt.Fscan(in, &t)

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

		fmt.Fscan(in, &n)
		fmt.Fscan(in, &k)

		arr := make([]int, n)

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

		// solve
		res := wonderfulPermutation(arr, n, k)
		fmt.Print(res)
	}
}

func wonderfulPermutation(arr []int, n, k int) int {
	if n == k {
		return 0
	}

	temp := make([]int, n)
	copy(temp, arr)
	sort.Ints(temp)
	seen := make(map[int]bool)

	for i := 0; i < k; i++ {
		seen[arr[i]] = true
	}

	count := 0
	for i := 0; i < k; i++ {
		if !seen[temp[i]] {
			count++
		}
	}
	return count
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "sort"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,x int
		fmt.Fscan(in,&n,&x)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			mapper[j]= list[j]
		}
		sort.Ints(list)
		counter:=0
		for j:=0;j<x;j++{
			if mapper[j] <= list[j] {
				continue
			} else {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

func arr(n, m int) [][]int {
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	return a
}

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

func main() {
	var t, n, k int
	t = readInt()
	for ; t != 0; t-- {
		n, k = readInt2()
		a := readInts(n)
		ans := 0
		for i := 1; i <= k; i++ {
			if i == a[i-1] {
				continue
			}
			for j := i + 1; j <= n; j++ {
				if a[j-1] == i {
					a[j-1], a[i-1] = a[i-1], a[j-1]
					ans++
					break
				}
			}
		}
		fmt.Println(ans)
	}
}


package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for j := 0; j < 2 * n; j++ {
        fmt.Printf(" ")
    }
    fmt.Printf("0\n")
    for i := 1; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(j, " ")
        }
        for j := i-1; j > 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("0\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(j, " ")
        }
        for j := 2*n - i; j > 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("0\n")
    }
}

package main

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

func printPattern(writer *bufio.Writer, n int) {
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			if j == i && i == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		fmt.Fprint(writer, "\n")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			if j == i && i == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j == 0 {
				fmt.Fprintf(writer, "%d", j)
			} else {
				fmt.Fprintf(writer, "%d ", j)
			}
		}
		fmt.Fprint(writer, "\n")
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	printPattern(writer, n)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				} else {
					continue
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j >= n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	m :=0
	t:=0
	for r:=-n; r<=n; r++ {
		if r<0 {
			m=r*(-1)
		} else {m=r}
		t= n-m
		for j:=0;j<m;j++ {
			fmt.Printf("  ")
		}
		for i:=0;i<t;i++ {
			fmt.Printf("%d ",i)
		}
		for i:=t;i>0;i-- {
			fmt.Printf("%d ",i)
		}
		fmt.Println("0")
	}
}

package main
import (
    "fmt"
)
func main() {
    var n int
    fmt.Scan(&n)
    m :=0
    t:=0
    for r:=-n; r<=n; r++ {// 1 + 2n
        if r<0 {
            m=r*(-1)
        } else {m=r}
        t= n-m
        for j:=0;j<m;j++ {// 1 + 2n
            fmt.Printf("  ")
        }
        for i:=0;i<t;i++ {// 1 + 2n
            fmt.Printf("%d ",i)
        }
        for i:=t;i>0;i-- {//1 +2n
            fmt.Printf("%d ",i)
        }
        fmt.Println("0")
    }
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 2*n+1; i++ {
		t := i - 1
		if i > n+1 {
			t = n - (i - n) + 1
		}
		numspace := n - t
		for k := 0; k < numspace; k++ {
			fmt.Print("  ")
		}
		for j := 0; j < t; j++ {
			fmt.Print(j)
			fmt.Print(" ")
		}
		fmt.Print(t)
		for j := t - 1; j >= 0; j-- {
			fmt.Print(" ")
			fmt.Print(j)
		}
		fmt.Println("")
	}

}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n+vi); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n+vi) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	k := 0
	arrayStr := make([]string, 2*n+1)

	for i := 0; i <= n; i++ {
		arrayStr[k] = ""
		for j := 0; j < 2*(n-i); j++ {
			arrayStr[k] += " "
		}
		for j := 0; j <= i; j++ {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		for j := i - 1; j >= 0; j-- {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		arrayStr[k] = strings.TrimSuffix(arrayStr[k], " ")
		k++
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			arrayStr[k] += " "
		}
		for j := 0; j <= i; j++ {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		for j := i - 1; j >= 0; j-- {
			arrayStr[k] += (strconv.Itoa(j) + " ")
		}
		arrayStr[k] = strings.TrimSuffix(arrayStr[k], " ")
		k++
	}
	for _, s := range arrayStr {
		fmt.Println(s)
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		max_num := n - abs(i)
		for j := 0; j < 2*max_num; j++ {
			fmt.Printf("%d ", min(j,abs(2*max_num-j)))
		}
		fmt.Println("0")
	}
}

func abs(n int) int{
	if n > 0{
		return n
	}else{
		return -n
	}
}

func min(num1 int, num2 int) int{
	if num1 < num2{
		return num1
	}else{
		return num2
	}
}

package main

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

var scanner *bufio.Scanner

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

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

  n := int(getI())
  for i := 0; i < 2*n+1; i++ {
    limit := i
    if limit > n {
      limit = 2*n - limit
    }
    for j := limit; j < n; j++ {
      writer.WriteString("  ")
    }
    writer.WriteString("0")
    if limit != 0 {
      for j := 1; j < limit; j++ {
        writer.WriteString(fmt.Sprintf(" %d", j))
      }
      for j := limit; j >= 0; j-- {
        writer.WriteString(fmt.Sprintf(" %d", j))
      }
    }
    writer.WriteString("\n")
  }
}

package main

import (
	"fmt"
)

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

	for t := 0; t < 2*n-1; t++ {
		var i int
		if t < n {
			i = t
		} else {
			i = 2*(n-1) - t
		}
		for j := i + 1; j < n*2-(i+1); j++ {
			fmt.Printf(" ")
		}
		for j := 0; j <= i; j++ {
			if i == 0 {
				fmt.Printf("%d", j)
			} else {
				fmt.Printf("%d ", j)
			}
		}
		for j := i - 1; j >= 0; j-- {
			if j != 0 {
				fmt.Printf("%d ", j)
			} else {
				fmt.Printf("%d", j)
			}
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		max_num := 3 - abs(i)
		for j := 0; j < 2*max_num; j++ {
			fmt.Printf("%d ", min(j,abs(2*max_num-j)))
		}
		fmt.Println("0")
	}
}

func abs(n int) int{
	if n > 0{
		return n
	}else{
		return -n
	}
}

func min(num1 int, num2 int) int{
	if num1 < num2{
		return num1
	}else{
		return num2
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		for j := 0; j < n-abs(i); j++ {
			fmt.Printf("%d ", j)
		}
		for j := n-abs(i); j>=0; j-- {
			fmt.Printf("%d ", j)
		}
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		fmt.Println("")
	}
}

func abs(n int) int{
	if n > 0{
		return n
	}else{
		return -n
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_,er := fmt.Scan(&n)
	if er != nil {
		os.Exit(1)
	}
	for i := -n; i <= n; i++ {
		for j := 0; j < abs(i); j++ {
			fmt.Print("  ")
		}
		for j := 0; j < n-abs(i); j++ {
			fmt.Printf("%d ", j)
		}
		for j := n-abs(i); j>=0; j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println("")
	}
}

func abs(n int) int{
	if n > 0{
		return n
	}else{
		return -n
	}
}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	m :=0
	for r:=-n; r<=n; r++ {
		if r<0 {
			m=r*(-1)
		} else {m=r}
		t:= n-m
		for i:=0;i<m;i++ {
			fmt.Printf(" ")
		}
		for i:=0;i<t;i++ {
			fmt.Printf("%d ",i)
		}
		for i:=t;i>0;i-- {
			fmt.Printf("%d ",i)
		}
		fmt.Println("0")
	}
}

package main

import (
	"fmt"
)

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

	for t := 0; t < 2*n-1; t++ {
		var i int
		if t < n {
			i = t
		} else {
			i = 2*(n-1) - t
		}
		for j := i + 1; j < n*2-(i+1); j++ {
			fmt.Printf(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Printf("%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Printf("%d ", j)
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for i := 0; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(" ", j)
        }
        for j := i-1; j >= 0; j-- {
            fmt.Print(" ", j)
        }
        fmt.Printf("\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(" ", j)
        }
        for j := 2*n - i; j >= 0; j-- {
            fmt.Print(" ", j)
        }
        fmt.Printf("\n")
    }
}

package main

import (
    "fmt"
)

func main() {
    var n int;
    fmt.Scan(&n)
    for i := 0; i <= n; i++ {
        for j := 0; j < 2 * (n - i); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j <= i; j++ {
            fmt.Print(j, " ")
        }
        for j := i-1; j >= 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("\n")
    }
    for i := n + 1; i <= 2 * n; i++ {
        for j := 0; j < 2 * (i - n); j++ {
            fmt.Printf(" ")
        }
        for j := 0; j < 2*n - i; j++ {
            fmt.Print(j, " ")
        }
        for j := 2*n - i; j >= 0; j-- {
            fmt.Print(j, " ")
        }
        fmt.Printf("\n")
    }
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n+i); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n+i) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i := 0; i <= (n*2); i++ {
        var vi int
        if i <= n { vi = i } else { vi = (n*2)-i }
        for j := 0; j <= (n*2); j++ {
            dist := vi-int(math.Abs(float64(j)-float64(n)))
            if dist < 0 { fmt.Print(" ") } else { fmt.Print(dist) }
            if j == (n*2) { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}

package main

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

func printPattern(writer *bufio.Writer, n int) {
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			fmt.Fprintf(writer, "%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Fprintf(writer, "%d ", j)
		}
		fmt.Fprint(writer, "\n")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Fprint(writer, " ")
		}
		for j := 0; j <= i; j++ {
			fmt.Fprintf(writer, "%d ", j)
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Fprintf(writer, "%d ", j)
		}
		fmt.Fprint(writer, "\n")
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanln(reader, &n)
	printPattern(writer, n)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				} else {
					continue
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j > n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				if j < n-l {
					fmt.Print(" ")
				}
			} else {
				k := l - dis(j, n)
				fmt.Print(l - dis(j, n))
				if j > n && k == 0 {
					continue
				}
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < 2*n+1; i++ {
		l := i
		if i > n {
			l = 2*n - i
		}

		for j := 0; j < 2*n+1; j++ {
			if j < n-l || j > n+l {
				fmt.Print(" ")
			} else {
				fmt.Print(l - dis(j, n))
			}
			fmt.Print(" ")
		}
		fmt.Println("")
	}
}

func dis(x, y int) int {
	d := x - y
	if d < 0 {
		d = -1 * d
	}

	return d
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i <= 2*n+1; i++ {
		t := i - 1
		if i > n+1 {
			t = n - (i - n)
		}
		numspace := n - t
		for k := 0; k < numspace; k++ {
			fmt.Print("  ")
		}
		for j := 0; j < t; j++ {
			fmt.Print(j)
			fmt.Print(" ")
		}
		fmt.Print(t)
		for j := t - 1; j >= 0; j-- {
			fmt.Print(" ")
			fmt.Print(j)
		}
		fmt.Println("")
	}

}

package main

import (
	"fmt"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("\b")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("\b")
	}
}

package main

import (
	"fmt"
)

type pair struct {
	first  int
	second int
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i <= n; i++ {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("")
	}
	for i := n - 1; i >= 0; i-- {
		for j := 0; j < 2*(n-i); j++ {
			fmt.Print(" ")
		}
		for j := 0; j <= i; j++ {
			fmt.Print(j, " ")
		}
		for j := i - 1; j >= 0; j-- {
			fmt.Print(j, " ")
		}
		fmt.Println("")
	}
}


package main

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

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

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

var letterCounts map[rune]int

func addLetter(r rune) {
	if count, ok := letterCounts[r]; ok {
		letterCounts[r] = count + 1
	} else {
		letterCounts[r] = 1
	}
}

func main() {
	defer writer.Flush()

	var t, n int
	var str string

	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		letterCounts = make(map[rune]int)

		scanf("%d\n", &n)
		for j := 0; j < n; j++ {
			scanf("%s\n", &str)

			for _, r := range str {
				addLetter(r)
			}
		}

		equal := true
		for _, count := range letterCounts {
			if count%n != 0 {
				equal = false
				break
			}
		}

		if equal {
			printf("YES")
		} else {
			printf("NO")
		}
		printf("\n")
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	s := make([]string, n)
	cnt := make([]int, 26)

	for i := range s {
		fmt.Scanf("%s\n", &s[i])
		for _, c := range s[i] {
			cnt[c - 'a']++
		}
	}
	for _, v := range cnt {
		if v % n != 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

func main() {
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanString := func(s *string) {
		scanner.Scan()
		text := scanner.Text()
		*s = text
	}

	scanInt := func(n *int) {
		scanner.Scan()
		num, _ := strconv.ParseInt(scanner.Text(), 10, 32)
		*n = int(num)
	}

	var n, w int
	var s string
	scanInt(&n) // number of cases

	for i := 0; i < n; i++ {
		scanInt(&w) // number of word
		chars := map[int32]int{}
		for j := 0; j < w; j++ {
			scanString(&s)
			for _, char := range s {
				if _, ok := chars[char]; ok {
					chars[char]++
				} else {
					chars[char] = 1
				}
			}
		}
		match := true
		for _, count := range chars {
			if count % w != 0 {
				match = false
			}
		}
		if match {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var str [1005]string

func main()  {
	t:=ReadInt()
	for i:=0;i<t;i++{
		n:=ReadInt()
		var bit [26]int
		for j:=0;j<n;j++{
			str[i]=ReadString()
			for _,val:= range str[i]{
				bit[val-'a']++
			}
		}
		f:=true
		for j:=0;j<26;j++{
			if(bit[j]%n!=0){
				fmt.Println("NO")
				f=false
				break
			}
		}
		if(f){
			fmt.Println("YES")
		}
	}
	close(out)
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _  := strconv.Atoi(intStr)
	return i
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

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

func main() {
	var t, n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		count := make(map[string]int, 0)
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &s)
			for _, v := range s {
				count[string(v)]++
			}
		}
		ans := "YES"
		for _, v := range count {
			if v%n != 0 {
				ans = "NO"
				break
			}
		}
		fmt.Println(ans)
	}

}

package main

import (
    "fmt"
)

func solve() {
    var n int
    var s string

    fmt.Scan(&n)
    dict := make(map[byte]int, 26)

    for i := 0; i < n; i++ {
        fmt.Scan(&s)
        for j := 0; j < len(s); j++ {
            _, ok := dict[s[j]]
            if !ok {
                dict[s[j]] = 1
            } else {
                dict[s[j]] += 1
            }
        }
    }

    for _, v := range dict {
        if v % n != 0 {
            fmt.Println("NO")
            return
        }
    }

    fmt.Println("YES")
}

func main() {
    var t int

    fmt.Scan(&t)

    for i := 0; i < t; i++ {
        solve()
    }
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := in(); t > 0; t-- {
		n := in()

		a := make([]string, n)

		for i := range a {
			a[i] = ins()
		}

		m := make(map[byte]int)

		for i := range a {
			for j := range a[i] {
				m[a[i][j]]++
			}
		}

		ok := true

		for _, v := range m {
			if v%n != 0 {
				ok = false
				break
			}
		}

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

/*
URL:
https://codeforces.com/contest/1397/problem/A
*/

package main

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

var (
	t int

	n int
	S [][]rune
)

func main() {
	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		S = [][]rune{}
		for i := 0; i < n; i++ {
			row := readrs()
			S = append(S, row)
		}
		// for _, R := range S {
		// 	PrintfDebug("%s\n", string(R))
		// }
		// PrintfDebug("\n")

		solve()
	}
}

func solve() {
	cnts := [30]int{}

	for i := 0; i < n; i++ {
		R := S[i]
		for _, c := range R {
			cnts[c-'a']++
		}
	}

	for i := 'a'; i <= 'z'; i++ {
		if cnts[i-'a']%n != 0 {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}

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

/********** common constants **********/

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

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

// modint can calculate a right residual whether value is positive or negative.
func modint(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import "fmt"

func main(){

	nCase := 0

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

	for i:=0;i<nCase;i++{
		line := 0
		_, err := fmt.Scanf("%d\n", &line)
		if err != nil {
			return
		}
		ss := []string{}
		for j:=0;j<line;j++{
			s := ""
			_, err := fmt.Scanf("%s\n", &s)
			if err != nil {
				return
			}
			ss = append(ss, s)
		}
		if judge(line, ss){
			fmt.Printf("YES\n")
		}else{
			fmt.Printf("NO\n")
		}
	}
}

func judge(line int, ss []string)bool{
	if line <= 0 || len(ss) == 0{
		return false
	}

	m := map[string]int{}   //记录字母的次数
	for _,s := range(ss){
		for _,c := range(s){
			m[string(c)]++
		}
	}

	//如果不能被整除的话，说明不符合要求
	for _,v := range(m){
		if v%line != 0{
			return false
		}
	}

	return true
}

package main

import "fmt"

const ERROR_EXIT int = -1

func main(){

	nCase := 0

	_,err := fmt.Scanf("%d", &nCase)
	if err != nil {
		return
	}

	for i:=0;i<nCase;i++{
		line := 0
		_, err := fmt.Scanf("%d", &line)
		if err != nil {
			return
		}
		ss := []string{}
		for j:=0;j<line;j++{
			s := ""
			_, err := fmt.Scanf("%s", &s)
			if err != nil {
				return
			}
			ss = append(ss, s)
		}
		if judge(line, ss){
			fmt.Printf("YES\n")
		}else{
			fmt.Printf("NO\n")
		}
	}
}

func judge(line int, ss []string)bool{
	if line <= 0 || len(ss) == 0{
		return false
	}

	m := map[string]int{}   //记录字母的次数
	for _,s := range(ss){
		for _,c := range(s){
			m[string(c)]++
		}
	}

	//如果不能被整除的话，说明不符合要求
	for _,v := range(m){
		if v%line != 0{
			return false
		}
	}

	return true
}


package main

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

const (
	mod = uint64(1e9 + 7)
)

func isPrime(q int) int {
	if q < 3 {
		return -1
	}
	for i := 2; i*i <= q; i++ {
		if q%i == 0 {
			return i
		}
	}
	return -1
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n+1)
	cur := 0
	for i := 2; i <= n; i++ {
		tmp := isPrime(i)
		if tmp == -1 {
			cur++
			a[i] = cur
		} else {
			a[i] = a[tmp]
		}
	}
	for i := 2; i <= n-1; i++ {
		fmt.Fprintf(out, "%d ", a[i])
	}
	fmt.Fprintf(out, "%d\n", a[n])
	return
}

// find num of elem >= k
func find(a []int, k int) int {
	if len(a) == 0 {
		return 0
	}
	n := len(a)
	if a[0] > k {
		return n
	}
	if a[n-1] < k {
		return 0
	}
	l := 0
	r := len(a) - 1
	for l < r {
		mid := (l + r) / 2
		if a[mid] < k {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return n - l
}

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

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n+1)
	x := 1
	for i := 2; i <= n; i++ {
		if a[i] == 0 {
			a[i] = x
			x++
		}
		for j := i * 2; j <= n; j += i {
			if a[j] == 0 {
				a[j] = a[i]
			}
		}
	}
	for i := 2; i <= n-1; i++ {
		fmt.Printf("%v ", a[i])
	}
	fmt.Printf("%v\n", a[n])
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	N := readi()
	a := make([]int, N+1)

	for i := 2; i < len(a); i += 2 {
		a[i] = 1
	}
	v := 2
	for k := 3; k < len(a); k += 2 {
		i := k
		if a[i] != 0 {
			continue
		}
		for ; i < len(a); i += k {
			a[i] = v
		}
		v++
	}
	sp := ""
	for i := 2; i < len(a); i++ {
		printf("%s%d", sp, a[i])
		sp = " "
	}
	println()

}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

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

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

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

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

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

package main

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

func Solve(n int) []int {
	a := make([]int, n+1)
	color := 1
	squareRoot := int(math.Sqrt(float64(n))) + 1
	for i := 2; i <= squareRoot; i++ {
		if a[i] == 0 {
			a[i] = color
			for j := i * i; j <= n; j += i {
				a[j] = color
			}
			color += 1
		}
	}
	for i := 2; i <= n; i++ {
		if a[i] == 0 {
			a[i] = color
			color += 1
		}
	}
	return a[2:]
}

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

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

	a := Solve(n)
	for _, elem := range a {
		fmt.Fprintf(writer, "%d ", elem)
	}
	fmt.Fprintf(writer, "\n")
}


package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO

const (
	inf = 1 << 30
)

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

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

func sol() {
	var n, m int
	n = myio.ReadInt()
	m = myio.ReadInt()
	a := make([]int, n)
	s := make([]int, n+1)
	s[0] = 0
	for i := 0; i < n; i++ {
		a[i] = myio.ReadInt()
		s[i+1] = s[i] + a[i]
	}
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
		for j := 0; j <= m; j++ {
			dp[i][j] = inf
		}
	}
	dp[0][0] = 0
	for k := m; k >= 0; k-- {
		for i := 0; i < n; i++ {
			for j := 0; j <= m-k; j++ {
				if dp[i][j] == inf {
					continue
				}
				var p=j+k
				dp[i+1][p] = min(dp[i+1][p], dp[i][j]+abs(p-s[i+1]))
			}
		}
	}
	myio.Println(dp[n][m])
}

func main() {
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func min(a,b int) int { if a > b { return b }; return a }
const inf  = 1000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N,M := gi(),gi(); A := gis(N);
	psum := make([]int,N); psum[0] = A[0]; for i:=1;i<N;i++ { psum[i] = psum[i-1] + A[i] }
	parr := make([]int,0,M); for i:=0;i<N;i++ { for j:=0;j<A[i];j++ { parr = append(parr,i) } }
	parrcum := make([]int,M+1); parrcum[0] = 0; for i:=0;i<M;i++ { parrcum[i+1] = parrcum[i] + parr[i] }
	// dp[i][j][k] = cheapest way to fix prefix through i with last term at least j pancakes and prefix sum == k
	dp := twodi(M+1,M+1,inf)
	ndp := twodi(M+1,M+1,inf)
	for j:=0;j<=M;j++ { if psum[0] >= j { dp[j][j] = psum[0]-j } else { dp[j][j] = parrcum[j] } }
	for j:=M-1;j>=0;j-- { for k:=j;k<=M;k++ { dp[j][k] = min(dp[j][k],dp[j+1][k]) } } // fixes the "at least" part
	for i:=1;i<N;i++ {
		for j:=0;j<=M;j++ { for k:=0;k<=M;k++ { ndp[j][k] = inf } }
		for j:=0;j<=M;j++ {
			for k:=j; k<=M; k++ {
				add := 0
				if psum[i] >= k {
					add = psum[i] - k
				} else {
					lend := min(j,k-psum[i])
					add = parrcum[k] - parrcum[k-lend] - i * lend
				}
				ndp[j][k] = dp[j][k-j] + add
			}
		}
		for j:=M-1;j>=0;j-- { for k:=j;k<=M;k++ { ndp[j][k] = min(ndp[j][k],ndp[j+1][k]) } }
		dp,ndp = ndp,dp
	}
	ans := dp[0][M]
	fmt.Println(ans)
}

package main

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

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

var MX int = 300

const MM int = 1000000

var N, M int
var A []int

func gen(n, m, l int, v int) [][][]int {
	dp := make([][][]int, n)
	for i := 0; int(i) < n; i++ {
		dp[i] = make([][]int, m)
		for j := 0; int(j) < m; j++ {
			dp[i][j] = make([]int, l)
		}
	}

	for i := 0; int(i) < n; i++ {
		for j := 0; int(j) < m; j++ {
			for k := 0; int(k) < l; k++ {
				dp[i][j][k] = v
			}
		}
	}
	return dp
}

func solve() int {
	dp_in := gen(2, MX, MX, MM)
	dp_out := gen(2, MX, MX, MM)

	for j := int(0); j+A[0] < MX; j++ {
		dp_in[0][j][j+A[0]] = 0
		for k := int(1); k < MX; k++ {
			dp_in[0][j][k] = min(dp_in[0][j][k-1], dp_in[0][j][k])
		}
	}

	for j := int(0); j <= A[0]; j++ {
		dp_out[0][j][A[0]-j] = 0
		for k := int(1); k < MX; k++ {
			dp_in[0][j][k] = min(dp_in[0][j][k-1], dp_in[0][j][k])
		}
	}

	for i := int(1); i < N; i++ {
		a := A[i]
		for j := int(0); j < MX; j++ {
			for k := int(0); k < MX; k++ {
				// in
				a = A[i] + j
				if a >= k {
					mi := int(MM)
					if a-k < MX {
						mi = min(mi, dp_in[(i-1)%2][a-k][k])
					}
					dp_in[i%2][j][k] = mi + a - k
				} else { // (i-1) is out
					mi := int(MM)
					if k-a < MX {
						mi = min(mi, dp_out[(i-1)%2][k-a][k])
					}
					dp_in[i%2][j][k] = mi + k - a
				}

				//out
				a = A[i] - j
				if a >= k {
					mi := int(MM)
					if a-k < MX {
						mi = min(mi, dp_in[(i-1)%2][a-k][k])
					}
					dp_out[i%2][j][k] = mi + a - k
				} else {
					mi := int(MM)
					if k-a < MX {
						mi = min(mi, dp_out[(i-1)%2][k-a][k])
					}
					dp_out[i%2][j][k] = mi + k - a
				}

			}

			for k := int(1); k < MX; k++ {
				dp_in[i%2][j][k] = min(dp_in[i%2][j][k], dp_in[i%2][j][k-1])
				dp_out[i%2][j][k] = min(dp_out[i%2][j][k], dp_out[i%2][j][k-1])
			}

		}
	}

	res := int(MM)
	for k := int(0); k < MX; k++ {
		res = min(res, dp_in[(N-1)%2][0][k])
		res = min(res, dp_out[(N-1)%2][0][k])
	}

	return res

}

func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &N, &M)
	MX = M + 1
	A = make([]int, N)
	for i := N - 1; int(i) >= 0; i-- {
		fmt.Fscan(in, &A[i])
	}

	fmt.Println(solve())
}

package main

import (
	"bufio"
	"fmt"
	"os"
	_ "runtime/pprof"
)

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	return x
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO

const (
	inf = 1 << 30
)

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

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

func sol() {
	var n, m int
	n = myio.ReadInt()
	m = myio.ReadInt()
	a := make([]int, n)
	s := make([]int, n+1)
	s[0] = 0
	for i := 0; i < n; i++ {
		a[i] = myio.ReadInt()
		s[i+1] = s[i] + a[i]
	}
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
		for j := 0; j <= m; j++ {
			dp[i][j] = inf
		}
	}
	dp[0][0] = 0
	for k := m; k >= 0; k-- {
		for i := 0; i < n; i++ {
			for j := 0; j <= m-k; j++ {
				if dp[i][j] == inf {
					continue
				}
				dp[i+1][j+k] = min(dp[i+1][j+k], dp[i][j]+abs(j+k-s[i+1]))
			}
		}
	}
	myio.Println(dp[n][m])
}

func main() {
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()
	sol()
}

package main

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

var wr = bufio.NewWriter(os.Stdout)
var rd = bufio.NewScanner(os.Stdin)

func nextInt() int {
	rd.Scan()
	if n, err := strconv.Atoi(rd.Text()); err == nil {
		return n
	}
	return 0
}
func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}
func main() {
	defer wr.Flush()
	rd.Buffer(make([]byte, 0), 1000000009)
	rd.Split(bufio.ScanWords)
	T := 1
	for Case := 0; Case < T; Case++ {
		solve()
	}
}

const N int = 255

var f [N][N][N]int

func solve() {
	for i1 := range f {
		for j := range f[i1] {
			for k := range f[i1][j] {
				f[i1][j][k] = 0x3f3f3f3f
			}
		}
	}
	n, m := nextInt(), nextInt()
	a := make([]int, n+2)
	s := make([]int, n+2)
	for i:=n;i>=1;i-- {
		a[i]=nextInt()
	}
	for i := 1; i <= n; i++ {
		s[i] = s[i-1] + a[i]
	}
	f[0][0][0] = 0
	for i := 1; i <= n; i++ {
		for j := 0; j <= m; j++ {
			minv := 0x3f3f3f3f
			for k := 0; j+k <= m; k++ {
				minv = Min(minv, f[i-1][j][k])
				f[i][j+k][k] = minv + Abs(s[i]-j-k)
			}
		}
	}
	res := 0x3f3f3f3f
	for p := 1; p <= m; p++ {
		res = Min(res, f[n][m][p])
	}
	fmt.Fprint(wr, res, "\n")
}

package main

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

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

const MX int64 = 300

var N, M int64
var A []int64

func gen(n, m, l int64, v int64) [][][]int64 {
	dp := make([][][]int64, n)
	for i := 0; int64(i) < n; i++ {
		dp[i] = make([][]int64, m)
		for j := 0; int64(j) < m; j++ {
			dp[i][j] = make([]int64, l)
		}
	}

	for i := 0; int64(i) < n; i++ {
		for j := 0; int64(j) < m; j++ {
			for k := 0; int64(k) < l; k++ {
				dp[i][j][k] = v
			}
		}
	}
	return dp
}

func solve() int64 {
	dp_in := gen(N, MX, MX, 10000)
	dp_out := gen(N, MX, MX, 10000)

	for j := int64(0); int64(j)+A[0] < MX; j++ {
		dp_in[0][j][j+A[0]] = 0
	}

	for j := int64(0); j <= A[0]; j++ {
		dp_out[0][j][A[0]-j] = 0
	}

	for i := int64(1); i < N; i++ {
		a := A[i]
		for j := int64(0); j < MX; j++ {
			for k := int64(0); k < MX; k++ {
				// in
				a = A[i] + j
				if a >= k {
					mi := int64(10000)
					for kk := int64(0); kk <= k; kk++ {
						if a-k >= 0 && a-k < MX {
							mi = min(mi, dp_in[i-1][a-k][kk])
						}
					}
					dp_in[i][j][k] = mi + a - k
				} else { // (i-1) is out
					mi := int64(10000)
					for kk := int64(0); kk <= k; kk++ {
						if k-a >= 0 && k-a < MX {
							mi = min(mi, dp_out[i-1][k-a][kk])
						}
					}
					dp_in[i][j][k] = mi + k - a
				}

				//out
				a = A[i] - j
				if a >= k {
					mi := int64(10000)
					for kk := int64(0); kk <= k; kk++ {
						if k-a >= 0 && k-a < MX {
							mi = min(mi, dp_in[i-1][a-k][kk])
						}
					}
					dp_out[i][j][k] = mi + a - k
				} else {
					mi := int64(10000)
					for kk := int64(0); kk <= k; kk++ {
						if k-a >= 0 && k-a < MX {
							mi = min(mi, dp_out[i-1][k-a][kk])
						}
					}
					dp_out[i][j][k] = mi + k - a
				}

			}
		}
	}

	res := int64(10000)
	for k := int64(0); k < MX; k++ {
		res = min(res, dp_in[N-1][0][k])
		res = min(res, dp_out[N-1][0][k])
	}

	return res

}

func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &N, &M)
	A = make([]int64, N)
	for i := N - 1; int64(i) >= 0; i-- {
		fmt.Fscan(in, &A[i])
	}

	fmt.Println(solve())
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	for {
		if _, err := fmt.Fscan(reader, &n); err != nil {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		gao(n, a)
	}
}

func gao(n int, a []int) {
	if n == 1 {
		fmt.Println("YES")
		fmt.Println(a[0], 1)
		return
	} // n > 1 below

	candidate := map[int]bool{}
	for i := 1; i < n; i++ {
		diff := abs(a[i] - a[i-1])
		if diff == 0 {
			fmt.Println("NO")
			return
		}
		if diff > 1 {
			candidate[diff] = true
		}
	}

	if len(candidate) == 0 {
		fmt.Println("YES")
		y := 0
		for i := 0; i < n; i++ {
			y = max(y, a[i])
		}
		fmt.Println(1, y)
		return
	}
	if len(candidate) > 1 {
		fmt.Println("NO")
		return
	}
	// len(candidate) == 1 below

	var y int
	for key := range candidate {
		y = key
	}
	const boundary = 1000 * 1000 * 1000
	if y > boundary {
		fmt.Println("NO")
		return
	}

	x := 0
	for _, av := range a {
		x = max(x, (av-1)/y+1)
	}
	if x > boundary {
		fmt.Println("NO")
		return
	}

	// fmt.Println("debug x, y", x, y)

	// Double check.
	for i := 1; i < n; i++ {
		x1, y1 := (a[i-1]-1)/y, (a[i-1]-1)%y
		x2, y2 := (a[i]-1)/y, (a[i]-1)%y
		if !(x1 == x2 || y1 == y2) {
			fmt.Println("NO")
			return
		}
		if x1 == x2 && y2-y1 != a[i]-a[i-1] {
			fmt.Println("NO")
			return
		}
		if y1 == y2 && sign(x2-x1)*y != a[i]-a[i-1] {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
	fmt.Println(x, y)
}

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

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

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

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	// max > y because minA is 1
	fmt.Println("YES")
	if n == 1 {
		fmt.Println(max, y)
		os.Exit(0)
	}
	fmt.Println(int64(1e9), y)
}

package main

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

func Init() {
}

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

	diffs := make(map[int]bool)
	for i := 1; i < N; i++ {
	  d := Abs(A[i] - A[i - 1])
	  if d == 0 {
	    io.Println("NO")
	    return
	  }
	  diffs[d] = true
	}
	delete(diffs, 1)

	if len(diffs) == 0 {
	  io.Println("YES")
	  io.Println("1000000000 1000000000")
	  return
	}
	if len(diffs) > 1 {
	  io.Println("NO")
	  return
	}

	var y int
	for k := range diffs {
	  y = k
	}

	for i := 1; i < N; i++ {
	  d := Abs(A[i] - A[i - 1])
	  if d == 1 && (A[i] - 1) / y != (A[i - 1] - 1) / y {
	    io.Println("NO")
	    return
	  }
	}
	io.Println("YES")
	io.Printf("1000000000 %d\n", y)
}

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

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

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

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

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

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

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

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

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

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

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

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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

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

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

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

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

package main

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

func Init() {
}

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

	diffs := make(map[int]bool)
	for i := 1; i < N; i++ {
	  d := Abs(A[i] - A[i - 1])
	  if d == 0 {
	    io.Println("NO")
	    return
	  }
	  diffs[d] = true
	}
	delete(diffs, 1)

	if len(diffs) == 0 {
	  io.Println("YES")
	  io.Println("1000000000 1000000000")
	  return
	}
	if len(diffs) > 1 {
	  io.Println("NO")
	  return
	}

	var y int
	for k := range diffs {
	  y = k
	}

	for i := 1; i < N; i++ {
	  d := Abs(A[i] - A[i - 1])
	  if d == 1 && (A[i] - 1) / y != (A[i - 1] - 1) / y {
	    io.Println("NO", i)
	    return
	  }
	}
	io.Println("YES")
	io.Printf("1000000000 %d\n", y)
}

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

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

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

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

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

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

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

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

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

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

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

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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

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

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

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}

	if n == 1 {
		fmt.Println("YES")
		fmt.Println(a[0], 1)
		return
	}

	candidate := map[int]bool{}
	for i := 1; i < n; i++ {
		diff := abs(a[i] - a[i-1])
		if diff > 1 {
			candidate[diff] = true
		}
	}

	if len(candidate) != 1 {
		fmt.Println("NO")
		return
	}

	var y int
	for key := range candidate {
		y = key
	}
	const boundary = 1000 * 1000 * 1000
	if y > boundary {
		fmt.Println("NO")
		return
	}

	x := 0
	for _, av := range a {
		x = max(x, (av-1)/y+1)
	}
	if x > boundary {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	fmt.Println(x, y)
}

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}

	candidate := map[int]bool{}
	for i := 1; i < n; i++ {
		diff := abs(a[i] - a[i-1])
		if diff > 1 {
			candidate[diff] = true
		}
	}

	if len(candidate) != 1 {
		fmt.Println("NO")
		return
	}

	var y int
	for key := range candidate {
		y = key
	}
	const boundary = 1000 * 1000 * 1000
	if y > boundary {
		fmt.Println("NO")
		return
	}

	x := 0
	for _, av := range a {
		x = max(x, (av-1)/y+1)
	}
	if x > boundary {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	fmt.Println(x, y)
}

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	for {
		if _, err := fmt.Fscan(reader, &n); err != nil {
			break
		}
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		gao(n, a)
	}
}

func gao(n int, a []int) {
	if n == 1 {
		fmt.Println("YES")
		fmt.Println(a[0], 1)
		return
	}

	candidate := map[int]bool{}
	for i := 1; i < n; i++ {
		diff := abs(a[i] - a[i-1])
		if diff == 0 {
			fmt.Println("NO")
			return
		}
		if diff > 1 {
			candidate[diff] = true
		}
	}

	if len(candidate) != 1 {
		fmt.Println("NO")
		return
	}

	var y int
	for key := range candidate {
		y = key
	}
	const boundary = 1000 * 1000 * 1000
	if y > boundary {
		fmt.Println("NO")
		return
	}

	x := 0
	for _, av := range a {
		x = max(x, (av-1)/y+1)
	}
	if x > boundary {
		fmt.Println("NO")
		return
	}

	// Double check.
	for i := 1; i < n; i++ {
		x1, y1 := (a[i-1]-1)/y, (a[i-1]-1)%y
		x2, y2 := (a[i]-1)/y, (a[i]-1)%y
		if !(x1 == x2 || y1 == y2) {
			fmt.Println("NO")
			return
		}
		if x1 == x2 && y2-y1 != a[i]-a[i-1] {
			fmt.Println("NO")
			return
		}
		if y1 == y2 && sign(x2-x1)*y != a[i]-a[i-1] {
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
	fmt.Println(x, y)
}

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

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

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

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	// max > y because minA is 1
	fmt.Println("YES")
	if n == 1 {
		fmt.Println(max, y)
		os.Exit(0)
	}
	fmt.Println(max/y+1, y)
}

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	fmt.Println(max/y+1, y)
}

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	// max > y because minA is 1
	fmt.Println("YES")
	fmt.Println(max/y, y)
}

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	// max > y because minA is 1
	fmt.Println("YES")
	fmt.Println(max/y+1, y)
}

package main

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

func main() {
	scanner, n := bufio.NewScanner(os.Stdin), 0
	scanner.Split(bufio.ScanWords)
	fmt.Scan(&n)
	a, max := make([]int, n), 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
		if a[i] > max {
			max = a[i]
		}
		if (i > 0) && (a[i-1] == a[i]) {
			// It is not allowed to stay in the same cell.
			fmt.Println("NO")
			os.Exit(0)
		}
	}

	y := 1
	for i := 0; i < (n - 1); i++ {
		d := a[i+1] - a[i]
		if d < 0 {
			d = -d
		}
		if d > 1 {
			if y == 1 {
				y = d
			}
			if y != d {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	if y > 1 {
		// Handle the bad +1, -1
		for i := 0; i < (n - 1); i++ {
			isBadPlusOne := (a[i]%y == 0) && (a[i] == (a[i+1] - 1))
			isBadMinusOne := (a[i]%y == 1) && (a[i] == (a[i+1] + 1))
			if isBadMinusOne || isBadPlusOne {
				fmt.Println("NO")
				os.Exit(0)
			}
		}
	}

	// max > y because minA is 1
	fmt.Println("YES")
	if n == 1 {
		fmt.Println(max, y)
		os.Exit(0)
	}
	fmt.Println(1e9, y)
}


// 38A-mic
package main

import (
    "fmt"
)

func main() {
    var n, a, b, sum int
    var m [10000]int
    fmt.Scan(&n)
    for i := 1; i <= n-1; i++ {
        fmt.Scan(&m[i])
    }
    fmt.Scan(&a, &b)
    for j := a; j <= b-1; j++ {
        sum += m[j]
    }
    fmt.Println(sum)
}

package main
import (
	"fmt"
	//"unicode/utf8"
	//"strconv"
)

func main() {
	var n,a,b int
	s:=0
	k:=make([]int,100)
	fmt.Scan(&n)
	for i:=1;i<n;i++ {
		fmt.Scan(&k[i])
	}
	fmt.Scan(&a,&b)
	for i:=a;i<b;i++ {
		s+=k[i]
	}
	fmt.Println(s)
}

package main

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

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

	di := make([]int, n+1)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		di[i] = a
	}

	var years int = 0
	for i := di[n-1]; i < di[n]; i++ {
		years += di[i-1]
	}

	fmt.Println(years)
}

package main

import "fmt"

func main() {
    var n,a,b int
    var d [105]int
    fmt.Scan(&n)
    for i := 1; i < n; i++ {
        fmt.Scan(&d[i])
    }
    fmt.Scan(&a,&b)
    ans := 0
    for a < b {
        ans += d[a]
        a++
    }
    fmt.Println(ans)
}

// 38A
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	y := 0
	d := [100]int{0}
	fmt.Scan(&n)
	for i := 1; i < n; i++ {
		fmt.Scan(&d[i])
	}
	fmt.Scan(&a, &b)
	for a < b {
		y += d[a]
		a++
	}
	fmt.Println(y)
}

// 38A
package main

import (
	"fmt"
)

func main() {
	var n, a, b, y int
	d := [100]int{0}
	fmt.Scan(&n)
	for i := 1; i < n; i++ {
		fmt.Scan(&d[i])
	}
	fmt.Scan(&a, &b)
	for i := a; i < b-1; i++ {
		y += d[i]
	}
	fmt.Println(y)
}


package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var t int
	var n, i, j, aux uint
	var b []uint

	for t, _ = fmt.Fscan(reader, &n); t == 1; t, _ = fmt.Fscan(reader, &n) {
		b = make([]uint, n)

		for i = 0; i < n; i++ {
			fmt.Fscan(reader, &b[i])
			aux = (n + b[i] - ((i * i) % n)) % n

			for j = 0; j < n; j++ {
				fmt.Fprint(writer, (((i*j)%n)+aux)%n)

				if j < n-1 {
					fmt.Fprint(writer, " ")
				}
			}

			fmt.Fprintln(writer)
		}
	}

	writer.Flush()
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	b := make([]int, n)
	for i := range b {
		Fscan(in, &b[i])
	}
	for i, v := range b {
		a := make([]int, n)
		a[i] = v
		k := i+1
		for j := 1; j < n; j++ {
			a[k%n] = (a[(k-1)%n] + i) % n
			k++
		}
		for _, v := range a {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}
}

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

package main

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

var in = bufio.NewReader(os.Stdin)

func read(out *int) error {
	var ans, sign int = 0, 1
	var readed = false
	c, err := in.ReadByte()
	for ; err == nil && (c < '0' || '9' < c); c, err = in.ReadByte() {
		if c == '-' {
			sign = -sign
		}
	}
	for ; err == nil && '0' <= c && c <= '9'; c, err = in.ReadByte() {
		ans = ans<<3 + ans<<1 + int(c-'0')
		readed = true
	}
	if readed {
		*out = ans * sign
		return nil
	}
	return err
}

var a [1000006]int

func main() {
	var n int
	read(&n)
	for i := 1; i <= n; i++ {
		read(&a[i])
	}
	for i := 1; i <= n; i++ {
		d := ((a[i]-i*i)%n + n) % n
		for j := 1; j <= n; j++ {
			fmt.Printf("%d ", (i*j+d)%n)
		}
		fmt.Println()
	}
}


package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func solve(n int, a []int) int {
	s := 0
	for _, v := range a {
		s += v
	}
	ans := 0
	lsum := 0
	for i := 0; i < n - 1; i++ {
		lsum += a[i]
		if (lsum == s - lsum) {
			ans += 1
		}
	}

	return ans
}

func main() {
	defer w.Flush()

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

	fmt.Fprintf(w, "%v", solve(n, a))
}

package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func solve(n int, a []int) int {
	s := 0
	for _, v := range a {
		s += v
	}
	ans := 0
	lsum := 0
	for i := 0; i < n - 1; i++ {
		lsum += a[i]
		if (lsum == s - lsum) {
			ans += 1
		}
	}

	return ans
}

func main() {
	defer w.Flush()

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

	fmt.Fprintf(w, "%v", solve(n, a))
}

package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	a := make([]int, n)
	dp := make([]int, n)
	s := 0
	lsum := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(r, "%d ", &a[i])
		s += a[i]
		lsum += a[i]
		dp[i] += lsum
	}
	ans := 0
	for i := 0; i < n - 1; i++ {
		if (dp[i] == s - dp[i]) {
			ans += 1
		}
	}

	fmt.Fprintf(w, "%v", ans)
}

package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func solve(n, s int, dp []int) int {
	ans := 0
	for i := 0; i < n - 1; i++ {
		if (dp[i] == s - dp[i]) {
			ans += 1
		}
	}

	return ans
}

func main() {
	defer w.Flush()

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

	fmt.Fprintf(w, "%v", solve(n, s, dp))
}