Shohag has an integer sequence $$$a_1, a_2, \ldots, a_n$$$. He can perform the following operation any number of times (possibly, zero):  Select any positive integer $$$k$$$ (it can be different in different operations).  Choose any position in the sequence (possibly the beginning or end of the sequence, or in between any two elements) and insert $$$k$$$ into the sequence at this position.  This way, the sequence $$$a$$$ changes, and the next operation is performed on this changed sequence. For example, if $$$a=[3,3,4]$$$ and he selects $$$k = 2$$$, then after the operation he can obtain one of the sequences $$$[\underline{2},3,3,4]$$$, $$$[3,\underline{2},3,4]$$$, $$$[3,3,\underline{2},4]$$$, or $$$[3,3,4,\underline{2}]$$$.Shohag wants this sequence to satisfy the following condition: for each $$$1 \le i \le |a|$$$, $$$a_i \le i$$$. Here, $$$|a|$$$ denotes the size of $$$a$$$.Help him to find the minimum number of operations that he has to perform to achieve this goal. We can show that under the constraints of the problem it's always possible to achieve this goal in a finite number of operations.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$)  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the initial length of the sequence. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the sequence.

For each test case, print a single integer  — the minimum number of operations needed to perform to achieve the goal mentioned in the statement.

NoteIn the first test case, we have to perform at least one operation, as $$$a_2=3>2$$$. We can perform the operation $$$[1, 3, 4] \rightarrow [1, \underline{2}, 3, 4]$$$ (the newly inserted element is underlined), now the condition is satisfied.In the second test case, Shohag can perform the following operations:$$$[1, 2, 5, 7, 4] \rightarrow [1, 2, \underline{3}, 5, 7, 4] \rightarrow [1, 2, 3, \underline{4}, 5, 7, 4] \rightarrow [1, 2, 3, 4, 5, \underline{3}, 7, 4]$$$.In the third test case, the sequence already satisfies the condition.

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		p, ans := 0, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			ans = Max(ans, p-j-1)
		}
		fmt.Fprintln(w, ans) // No idea why previous solution fails. Some missed corner case.
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	var ans int
	for i, v := range a {
		ans = max(ans, v-i-1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		var tally int
		for j:=0;j<n;j++{
			if list[j] > j+1 {
				if list[j] - (j+1) > tally {
					tally=list[j]-(j+1)
				}
			}
		}
		fmt.Fprintln(out,tally)
	}
}

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 int64
		fmt.Fscan(in, &n)

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

			if v > i+1 && v-i-1 > shift {
				shift = v - i - 1
			}
		}
		fmt.Fprintln(out, shift)
	}
}

package main

import (
	"fmt"
)

func getInt(p *int) {
	for {
		_, err := fmt.Scanf("%d", p)
		if err == nil {
			break
		}
	}
}

func proc() {
	var n, x int
	k := 0
	ans := 0
	getInt(&n)
	for j := 1; j <= n; j++ {
		k++
		getInt(&x)
		if x > k {
			ans += x - k
			k = x
		}
	}
	fmt.Println(ans)
}

func main() {
	var t int = 0
	getInt(&t)
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		B := make([]int, 1)
		for i := 1; i <= n; i++ {
			var q int
			fmt.Fscan(input, &q)
			if q > i {
				B = append(B, q-i)
			}
		}
		sort.Ints(B)
		qq := len(B)
		fmt.Println(B[qq-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var T, N int
var A int

func main() {
	defer out.Flush()

	fmt.Fscan(in, &T)
	var ans int
	for ; T > 0; T-- {
		fmt.Fscan(in, &N)
		ans = 0
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &A)
			if v := A - i - 1; v > ans {
				ans = v
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

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

	t := readInt(reader)

	for t > 0 {
		readInt(reader)
		a := readArrayInt64(reader)

		var sum int64 = 0
		for i, v := range a {
			if v > int64(i+1) + sum {
				sum += v - (int64(i+1)+sum)
			}
		}

		fmt.Fprintln(writer, sum)

		t--
	}

	writer.Flush()
}

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

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

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

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

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

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

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

	return value
}

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

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

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

	var ar []int

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

	return ar
}

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

	var ar []int64

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

	return ar
}

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

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

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1604A
Date: 14/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1604/A
Problem: CF1604A
**/
func (in *CF1604A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		index := 1
		ans := 0
		for i := 0; i < n; i++ {
			num := in.NextInt()
			if index < num {
				ans += num - index
				index += num - index
			}
			index++
		}
		fmt.Println(ans)
	}
}

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

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

package main

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

var n int
var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

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

		ans := solve()

		fmt.Println(ans)
	}
}

func solve() int {
	var ans int

	for i := 0; i < n; i++ {
		if a[i] > i + 1 {
			diff := a[i] - i - 1
			ans = max(ans, diff)
		}
	}
	return ans
}

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

package main

import "fmt"

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

}
func main() {
	var t int
	for fmt.Scan(&t);t>0;t--{
		var n int
		fmt.Scan(&n)
		ans:=0
		for i:=1;i<=n;i++ {
			var num int
			fmt.Scan(&num)
			num=max(num-i,0)
			ans=max(ans,num)
		}
		fmt.Println(ans)
	}

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	var x int
	for i, v := range a {
		if x < v-i-1 {
			x = v - i - 1
		}
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var t, n int16
	var a, v, c int32
	fmt.Fscan(inp, &t)
	for ; t > 0; t-- {
		fmt.Fscan(inp, &n)
		c, v = 0, 1
		for ; n > 0; n-- {
			fmt.Fscan(inp, &a)
			if a > v {
				c += a - v
				v = a
			}
			v++
		}
		fmt.Fprintf(out, "%v\n", c)
	}
}

package main

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

/*
4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969
---
1
3
0
696966
=========
1
5
3 4 6 2 10
---
5 -> 1 1 3 4 1 6 2 1 1 10
*/

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

	bld := strings.Builder{}

	var t int
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		insertCnt := 0

		idx := 1

		for i := 1; i <= n; i++ {
			var num int
			scanf("%d", &num)

			diff := num - idx
			if diff > 0 {
				insertCnt += diff
				idx += diff
			}

			idx++
		}
		scanf("\n")

		fmt.Fprintln(&bld, insertCnt)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst rune
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

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

	return true
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    ans := 0
    for i := 0; i < n; i++ {
        var tmp int
        fmt.Fscan(input, &tmp)
        ans = max(ans, tmp - i - 1)
    }
    fmt.Fprintln(output, ans)
}

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

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

package main

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

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

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, m int
		fmt.Fscan(in, &n)
		for i := 1; i <= n; i++ {
			var a int
			fmt.Fscan(in, &a)
			m++
			if m < a {
				m = a
			}
		}
		fmt.Fprintln(out, m-n)
	}
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		p, mx, k := 0, -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			if p > mx {
				mx, k = p, j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] > mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] >= mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, Max(mx-k-1, 0))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, mx, k := make([]int, n), -1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			if o[j] >= mx {
				mx, k = o[j], j
			}
		}
		fmt.Fprintln(w, (mx - k - 1))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, tot, it, p := make([]int, n), 0, 1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		for j := 0; j < n; j++ {
			if o[j] > p {
				tot += Max(o[j]-p-it, 0)
				p, it = o[j], 1
			} else {
				it++
			}
		}
		fmt.Fprintln(w, tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		n := 0
		fmt.Fscan(f, &n)
		o, tot, it, p := make([]int, n), 0, 1, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		for j := 0; j < n; j++ {
			if o[j] > p {
				tot += (o[j] - p - it)
				p, it = o[j], 1
			} else {
				it++
			}
		}
		fmt.Fprintln(w, tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int64
	scan(&n)
	var a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int64) int64 {
		if i > j {
			return i
		}
		return j
	}
	var ans, idx int64
	for i, v := range a {
		idx = max(idx, int64(i)+1)
		ans += max(0, v-idx)
		idx = max(idx, v+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int64
	scan(&n)
	var a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int64) int64 {
		if i > j {
			return i
		}
		return j
	}
	var ans, idx int64
	for i, v := range a {
		idx = max(idx, int64(i)+1)
		if v <= idx {
			continue
		}
		ans += v - idx
		idx = v + 1
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	ans, j := 0, 1
	for idx, i := range a {
		j = max(j, idx+1)
		ans += max(0, i-j)
		j = max(j, i+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		A()
	}
}

func A() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	max := func(i, j int) int {
		if i > j {
			return i
		}
		return j
	}
	ans, j := 0, 1
	for _, i := range a {
		ans += max(0, i-j)
		j = max(j, i+1)
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=0;j<n;j++{
			if list[j] > j+1 {
				tally++
			}
		}
		if max > n {
			fmt.Fprintln(out,max-n+tally)
		} else {
			fmt.Fprintln(out,tally)
		}

	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=1;j<n;j++{
			if list[j] < list[j-1] {
				tally++
			}
		}
		if max > n {
			fmt.Fprintln(out,max-n+tally)
		} else {
			fmt.Fprintln(out,tally)
		}

	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,max int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j]>max || j==0{
				max=list[j]
			}
		}
		var tally int
		for j:=1;j<n;j++{
			if list[j] < list[j-1] {
				tally++
			}
		}
		fmt.Fprintln(out,max-n+tally)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

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

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

			if v > i+1 && v-i+1 > shift {
				shift = v - i - 1
			}
		}
		fmt.Fprintln(out, shift)
	}
}

package main

import (
	"fmt"
)

func proc() {
	var n, x, k int
	k = 0
	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		k++
		fmt.Scanf("%d", &x)
		if x > k {
			k = x
		}
	}
	fmt.Println(k)
}

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		B := make([]int, 1)
		for i := 1; i <= n; i++ {
			var q int
			fmt.Fscan(input, &q)
			if q > i {
				B = append(B, q-i)
			}
		}
		q := len(B)
		fmt.Println(B[q-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var T, N int
var A int

func main() {
	defer out.Flush()

	fmt.Fscan(in, &T)
	var ans int
	for ; T > 0; T-- {
		fmt.Fscan(in, &N)
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &A)
			if v := A - i - 1; v > ans {
				ans = v
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

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

	t := readInt(reader)

	for t > 0 {
		readInt(reader)
		a := readArrayInt64(reader)

		var sum int64 = 0
		for i, v := range a {
			if v > int64(i) {
				sum += v - (int64(i+1)+sum)
			}
		}

		fmt.Fprintln(writer, sum)

		t--
	}

	writer.Flush()
}

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

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

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

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

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

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

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

	return value
}

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

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

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

	var ar []int

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

	return ar
}

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

	var ar []int64

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

	return ar
}

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

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

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

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


Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.Valera absolutely accidentally got a piece of ancient parchment on which an array of numbers was written. He immediately thought that the numbers in this array were not random. As a result of extensive research Valera worked out a wonderful property that a magical array should have: an array is defined as magic if its minimum and maximum coincide.He decided to share this outstanding discovery with you, but he asks you for help in return. Despite the tremendous intelligence and wit, Valera counts very badly and so you will have to complete his work. All you have to do is count the number of magical subarrays of the original array of numbers, written on the parchment. Subarray is defined as non-empty sequence of consecutive elements.

The first line of the input data contains an integer n (1 ≤ n ≤ 105). The second line contains an array of original integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).

Print on the single line the answer to the problem: the amount of subarrays, which are magical. Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).

NoteNotes to sample tests:Magical subarrays are shown with pairs of indices [a;b] of the beginning and the end.In the first sample: [1;1], [2;2], [3;3], [4;4], [2;3].In the second sample: [1;1], [2;2], [3;3], [4;4], [5;5], [1;2], [2;3], [1;3].

//83A
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn, x int
	var aa, t, y int64
	x=0
	y=2
	t=0
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.Atoi(r.Text())

	for i:=1; i<=nn; i++ {
		r.Scan()
		aa, _ = strconv.ParseInt(r.Text(), 0, 64)
		if aa==y {
			x+=1
		} else {
			x=1
			y=aa
		}
		t+=int64(x)
	}
	fmt.Println(t)
}

// 83A
package main

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

func main() {
	var i, k, n, s, x, y int64
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &x)
	s = n
	for i = 2; i <= n; i++ {
		fmt.Fscan(in, &y)
		if x == y {
			k++
			s += k
		} else {
			k = 0
		}
		x = y
	}
	fmt.Print(s)
}

// 83A
package main

import (
	"fmt"
)

func main() {
	var i, k, n, s, x, y int64
	fmt.Scan(&s)
	fmt.Scan(&x)
	s = n
	for i = 2; i <= n; i++ {
		fmt.Scan(&y)
		if x == y {
			k++
			s += k
		} else {
			k = 0
		}
		x = y
	}
	fmt.Print(s)
}


Long time ago there was a symmetric array $$$a_1,a_2,\ldots,a_{2n}$$$ consisting of $$$2n$$$ distinct integers. Array $$$a_1,a_2,\ldots,a_{2n}$$$ is called symmetric if for each integer $$$1 \le i \le 2n$$$, there exists an integer $$$1 \le j \le 2n$$$ such that $$$a_i = -a_j$$$.For each integer $$$1 \le i \le 2n$$$, Nezzar wrote down an integer $$$d_i$$$ equal to the sum of absolute differences from $$$a_i$$$ to all integers in $$$a$$$, i. e. $$$d_i = \sum_{j = 1}^{2n} {|a_i - a_j|}$$$.Now a million years has passed and Nezzar can barely remember the array $$$d$$$ and totally forget $$$a$$$. Nezzar wonders if there exists any symmetric array $$$a$$$ consisting of $$$2n$$$ distinct integers that generates the array $$$d$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases.  The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). The second line of each test case contains $$$2n$$$ integers $$$d_1, d_2, \ldots, d_{2n}$$$ ($$$0 \le d_i \le 10^{12}$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print "YES" in a single line if there exists a possible array $$$a$$$. Otherwise, print "NO". You can print letters in any case (upper or lower).

NoteIn the first test case, $$$a=[1,-3,-1,3]$$$ is one possible symmetric array that generates the array $$$d=[8,12,8,12]$$$.In the second test case, it can be shown that there is no symmetric array consisting of distinct integers that can generate array $$$d$$$.

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
    if (v%4 == 0) {
      return false
    }
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] <= temp) {
    return false
  }
  temp += (keys[i] - temp) /((i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
  //
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.ParseInt(input.Text(), 10, 64)
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.ParseInt(str[j], 10, 64)
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
		if i-2 >= 0 && d[i-2] == d[i] {
			return "NO"
		}
	}
	cum := int64(0)
	rem := n
	for i := len(d) - 2; i >= 0; i -= 2 {
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x <= 0 || x&1 != 0 {
			return "NO"
		}
		cum += x
		rem--
	}
	return "YES"
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int64{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,(d[i]-d[i-1])/int64(cnt*2))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 1000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

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

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

	var t int
	var n int64
	fmt.Fscan(in, &t)

MainLoop:
	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		d := make([]int64, 2*n)
		for i := int64(0); i < 2*n; i++ {
			fmt.Fscan(in, &d[i])
		}
		sort.Slice(d, func(i, j int) bool {
			return d[i] > d[j]
		})
		a := make([]int64, n)
		outerSum := int64(0)
		for i := int64(0); i < n; i++ {
			if d[2*i] != d[2*i+1] || (d[2*i]-outerSum)%(2*(n-i)) != 0 || outerSum >= d[2*i] {
				fmt.Println("NO")
				continue MainLoop
			}
			a[i] = (d[2*i] - outerSum) / (2 * (n - i))
			outerSum += 2 * a[i]
			if i > 0 && a[i] >= a[i-1] {
				fmt.Println("NO")
				continue MainLoop
			}
		}

		fmt.Println("YES")
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		D := make([]int64, 2*n)
		var pos int
		var tmp uint64
		s, _ := reader.ReadBytes('\n')
		for i := 0; i < 2*n; i++ {
			pos = readUint64(s, pos, &tmp) + 1
			D[i] = int64(tmp)
		}

		res := solve(n, D)

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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(n int, A []int64) bool {
	// don't care the ordering,
	sort.Slice(A, func(i, j int) bool {
		return A[i] > A[j]
	})

	B := make([]int64, n)

	for i := 0; i < n; i++ {
		if A[2*i] != A[2*i+1] {
			return false
		}
		B[i] = A[2*i]
	}

	D := make([]int64, n)
	for i := 1; i < n; i++ {
		if B[i-1] == B[i] || (B[i-1]-B[i])%(2*int64(n-i)) > 0 {
			return false
		}
		D[i] = (B[i-1] - B[i]) / 2 / int64(n-i)
	}

	for i := 1; i < n; i++ {
		B[n-1] -= 2 * int64(i) * D[i]
	}

	if B[n-1] <= 0 || B[n-1]%(2*int64(n)) > 0 {
		return false
	}
	return true
}

package main

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

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

	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int64, 2*n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Slice(a, func(i, j int) bool { return a[i] > a[j] })
		s := int64(0)
		for i := 0; i < 2*n; i += 2 {
			v := (a[i] - s) / int64(2*n-i)
			if a[i] != a[i+1] || a[i] <= s || (a[i]-s)%int64(2*n-i) > 0 || i > 0 && v >= a[i-2] {
				Fprintln(out, "NO")
				continue o
			}
			a[i] = v
			s += v * 2
		}
		Fprintln(out, "YES")
	}
}

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

package main

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

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

	var T, n int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int64, 2*n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Slice(a, func(i, j int) bool { return a[i] > a[j] })
		s, vis := int64(0), map[int64]bool{}
		for i := 0; i < 2*n; i += 2 {
			v := (a[i] - s) / int64(2*n-i)
			if a[i] != a[i+1] || a[i] <= s || (a[i]-s)%int64(2*n-i) > 0 || vis[v] {
				Fprintln(out, "NO")
				continue o
			}
			vis[v] = true
			s += v * 2
		}
		Fprintln(out, "YES")
	}
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	//. "testgo/helpers"
)

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

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

func main() {
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		n := 0
		scan(&n)

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

		solve(a)
	}

	writer.Flush()
}

func solve(a []int64) {
	N := len(a)

	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
	for i := 0; i < len(a); i += 2 {
		if a[i] != a[i+1] {
			printf("NO\n")
			return
		}
	}
	a = UniqueInts(a)

	if len(a) != N/2 {
		printf("NO\n")
		return
	}

	dist := make([]int64, len(a)-1)
	for i := range dist {
		if (a[i+1]-a[i])%int64(2*(i+1)) != 0 {
			printf("NO\n")
			return
		}
		dist[i] = (a[i+1] - a[i]) / int64(2*(i+1))
	}

	d0 := int64(0)
	for i := 0; i < len(dist); i++ {
		d0 += dist[i] * int64(len(a)-1-i)
	}

	if (a[0] - 2*d0) <= 0 {
		printf("NO\n")
		return
	}

	if (a[0]-2*d0)%int64(2*len(a)) == 0 {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

func UniqueInts(v []int64) []int64 {
	prev := int64(0)
	if len(v) > 0 && v[0] == prev {
		prev = -1
	}

	i := 0
	for j := range v {
		if v[j] != prev {
			prev = v[j]
			v[i], v[j] = v[j], v[i]
			i++
		}
	}

	return v[:i]
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
    if (v/4 == 0) {
      return false
    }
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] <= temp) {
    return false
  }
  temp += (keys[i] - temp) /((i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
  //
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.ParseInt(input.Text(), 10, 64)
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.ParseInt(str[j], 10, 64)
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] <= temp) {
    return false
  }
  temp += (keys[i] - temp) /((i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
  //
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.ParseInt(input.Text(), 10, 64)
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.ParseInt(str[j], 10, 64)
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
  //
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.ParseInt(str[j], 10, 64)
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
  //
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 100 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
  if n == 1 {
    return items[0] % 2 == 0 && items[0] == items[1]
  }
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  //fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func calc(items []int64, n int64) bool {
	sum := int64(0)
	m := make(map[int64]int)
	for _, i := range items {
		if i%2 != 0 {
			return false
		}
		sum += i
		m[i] += 1
	}
	keys := make([]int64, 0)
	if sum%4 != 0 {
		return false
	}
	for k, v := range m {
		if v%2 != 0 {
			return false
		}
		for i := 0; i < v/2; i++ {
			keys = append(keys, k)
		}
	}
  temp := int64(0)
	sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
  for i := n-1; i >= 0; i-- {
	if (keys[i] - temp) %(2*(i+1)) != 0 {
		return false
	}
  if (keys[i] == temp) {
    return false
  }
  temp += 2*(keys[i] - temp) /(2*(i+1))
  fmt.Println(i, keys, temp)
}

	return true
}

func main() {
	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	input := bufio.NewScanner(os.Stdin)
	input.Buffer(buf, maxCapacity)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	results := make([]bool, 0)
	for i := 0; i < t; i++ {
		input.Scan()
		q, _ := strconv.Atoi(input.Text())
		input.Scan()
		str := strings.Split(input.Text(), " ")
		items := make([]int64, 0)
		for j := int64(0); j < 2*int64(q); j++ {
			item, _ := strconv.Atoi(str[j])
			items = append(items, int64(item))
		}

		results = append(results, calc(items, int64(q)))
	}

	for _, result := range results {
		if result {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := int64(0)
	rem := n
	for i := len(d) - 2; i >= 0; i -= 2 {
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x <= 0 || x&1 != 0 {
			return "NO"
		}
		cum += x
		rem--
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	if !valid(cum) {
		return "NO"
	}
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if !valid(x) {
			return "NO"
		}
		cum += x
	}
	return "YES"
}

func valid(x int64) bool {
	return x > 0 && x&1 == 0
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	if cum&1 == 1 {
		return "NO"
	}
	prev := cum
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x <= 0 || x&1 == 1 || x >= prev {
			return "NO"
		}
		cum += x
		prev = x
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	prev := cum
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x <= 0 || x & 1 == 1 || x >= prev {
			return "NO"
		}
		cum += x
		prev = x
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	prev := cum
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x <= 0 || x >= prev {
			return "NO"
		}
		cum += x
		prev = x
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	prev := cum
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x == 0 || x >= prev {
			return "NO"
		}
		cum += x
		prev = x
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		tmp := d[i] - cum
		if tmp%rem != 0 {
			return "NO"
		}
		x := tmp / rem
		if x == 0 {
			return "NO"
		}
		cum += x
	}
	return "YES"
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

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

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

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

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

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

func sol(n int64, d []int64) string {
	sort.Slice(d, func(il, ir int) bool {
		return d[il] < d[ir]
	})
	for i := 0; i < len(d); i += 2 {
		if d[i] != d[i+1] {
			return "NO"
		}
		if d[i]&1 != 0 {
			return "NO"
		}
	}
	cum := d[len(d)-2] / n
	prev := cum
	rem := n
	for i := len(d) - 4; i >= 0; i -= 2 {
		rem--
		// d[i] = rem*2x + 2cum
		// => d[i]/2 = rem*x + cum
		// => d[i]/2 - cum = rem*x
		// => (d[i]/2 - cum) / rem = x
		if (d[i]/2-cum)%(rem) != 0 {
			return "NO"
		}
		x := (d[i]/2 - cum) / rem
		if x >= prev {
			return "NO"
		}
		cum += x
		prev = x
	}
	return "YES"
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int64{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,(d[i]-d[i-1])/int64(cnt*2))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 1000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				if t==1{
					fmt.Println("hi")
				}
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int64{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,(d[i]-d[i-1])/int64(cnt*2))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 1000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			fmt.Println(sum,m)
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				if t==1{
					fmt.Println("hi")
				}
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,int((d[i]-d[i-1])/int64(cnt*2)))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 1000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				if t==1{
					fmt.Println("hi")
				}
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,int((d[i]-d[i-1])/int64(cnt*2)))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 1000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,int((d[i]-d[i-1])/int64(cnt*2)))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = 5000000000000
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,int((d[i]-d[i-1])/int64(cnt*2)))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = math.MaxInt32*90
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
)
type darr []int64

func (a darr)Len()int{
	return len(a)
}
func (a darr)Swap(i, j int){
	a[i],a[j] = a[j],a[i]
}
func (a darr)Less(i, j int)bool{
	return a[i]<a[j]
}
func main() {
	 in:= bufio.NewReader(os.Stdin)
	 out := os.Stdout
	 var t int
	 fmt.Fscan(in,&t)
	 for u:=1;u<=t;u++{
	 	var n int
	 	fmt.Fscan(in,&n)
	 	d := make(darr,2*n)
	 	for i:=0;i<2*n;i++{
	 		fmt.Fscan(in,&d[i])
		}
		flag := true
		sort.Sort(d)
		gap := []int{}
		cnt := 0
		for i:=0;i<len(d);i+=2{
			if d[i]%2!=0{
				flag = false
				break
			}
			if d[i]!=d[i+1]{
				flag = false
				break
			}
			if i!=0{
				if d[i-1]==d[i]{
					flag = false
					break
				}
				if (d[i]-d[i-1])%int64(cnt*2)!=0{
					flag = false
					break
				}
				gap = append(gap,int((d[i]-d[i-1])/int64(cnt*2)))
			}
			cnt++
		}
		if !flag{
			fmt.Fprintln(out,"NO")
			continue
		}
		var l, r int64
		l = 1
		r = math.MaxInt32*10
		var ans int64
		ans = -1
		for l<=r{
			m := (l+r)>>1
			sum := m*2
			lst := m
			for i:=0;i<len(gap);i++{
				sum += (lst+int64(gap[i]))*2
				lst = lst + int64(gap[i])
			}
			if sum < d[0]{
				l = m+1
			}else if sum > d[0]{
				r = m-1
			}
			if sum == d[0]{
				ans = m
				break
			}
		}
		if ans != -1{
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	 }
}

package main

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

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

	var t int
	var n int64
	fmt.Fscan(in, &t)

MainLoop:
	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		d := make([]int64, 2*n)
		for i := int64(0); i < 2*n; i++ {
			fmt.Fscan(in, &d[i])
		}
		sort.Slice(d, func(i, j int) bool {
			return d[i] > d[j]
		})
		a := make([]int64, n)
		outerSum := int64(0)
		for i := int64(0); i < n; i++ {
			if d[2*i] != d[2*i+1] || (d[2*i]-outerSum)%(2*(n-i)) != 0 {
				fmt.Println("NO")
				continue MainLoop
			}
			a[i] = (d[2*i] - outerSum) / (2 * (n - i))
			outerSum += 2 * a[i]
			if a[i] == 0 || i > 0 && a[i] >= a[i-1] {
				fmt.Println("NO")
				continue MainLoop
			}
		}

		fmt.Println("YES")
	}
}

package main

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

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

	var t int
	var n int64
	fmt.Fscan(in, &t)

MainLoop:
	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		d := make([]int64, 2*n)
		for i := int64(0); i < 2*n; i++ {
			fmt.Fscan(in, &d[i])
		}
		sort.Slice(d, func(i, j int) bool {
			return d[i] > d[j]
		})
		a := make([]int64, n)
		outerSum := int64(0)
		for i := int64(0); i < n; i++ {
			if d[2*i] != d[2*i+1] || (d[2*i]-outerSum)%(2*(n-i)) != 0 {
				fmt.Println("NO")
				continue MainLoop
			}
			a[i] = (d[2*i] - outerSum) / (2 * (n - i))
			outerSum += 2 * a[i]
			if a[i] == 0 || i > 0 && a[i] == a[i-1] {
				fmt.Println("NO")
				continue MainLoop
			}
		}

		fmt.Println("YES")
	}
}

package main

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

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

	var t int
	var n int64
	fmt.Fscan(in, &t)

MainLoop:
	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		d := make([]int64, 2*n)
		for i := int64(0); i < 2*n; i++ {
			fmt.Fscan(in, &d[i])
		}
		sort.Slice(d, func(i, j int) bool {
			return d[i] > d[j]
		})
		a := make([]int64, n)
		outerSum := int64(0)
		for i := int64(0); i < n; i++ {
			if d[2*i] != d[2*i+1] || (d[2*i]-outerSum)%(2*(n-i)) != 0 {
				fmt.Println("NO")
				continue MainLoop
			}
			a[i] = (d[2*i] - outerSum) / (2 * (n - i))
			outerSum += 2 * a[i]
			if a[i] == 0 {
				fmt.Println("NO")
				continue MainLoop
			}
		}

		fmt.Println("YES")
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		D := make([]int64, 2*n)
		var pos int
		var tmp uint64
		s, _ := reader.ReadBytes('\n')
		for i := 0; i < 2*n; i++ {
			pos = readUint64(s, pos, &tmp) + 1
			D[i] = int64(tmp)
		}

		res := solve(n, D)

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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(n int, D []int64) bool {
	// don't care the ordering,
	sort.Slice(D, func(i, j int) bool {
		return D[i] < D[j]
	})
	var prev int64 = 1 << 30
	N := 2 * n
	var L int64
	var cnt int
	for i := N - 1; i > 0; i -= 2 {
		if D[i] != D[i-1] {
			// pair A[l] & A[r], A[l] = -A[r]
			return false
		}
		// L - cnt * A[i] + cnt * (-A[i]) - R + (N - 2 * cnt) * A[i] = D[i]
		// R = -L
		// 2 * L - 2 * cnt * A[i] + (N - 2 * cnt) * A[i] = D[i]
		// (N - 4 * cnt) * A[i] = D[i] - L
		a := (D[i] - 2*L) / int64(N-2*cnt)
		if a <= 0 || a*int64(N-2*cnt) != (D[i]-2*L) || a >= prev {
			return false
		}
		prev = a
		L += a
		cnt++
	}
	return true
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		D := make([]int64, 2*n)
		var pos int
		var tmp uint64
		s, _ := reader.ReadBytes('\n')
		for i := 0; i < 2*n; i++ {
			pos = readUint64(s, pos, &tmp) + 1
			D[i] = int64(tmp)
		}

		res := solve(n, D)

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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(n int, D []int64) bool {
	// don't care the ordering,
	sort.Slice(D, func(i, j int) bool {
		return D[i] < D[j]
	})

	N := 2 * n
	var L int64
	var cnt int
	for i := N - 1; i > 0; i -= 2 {
		if D[i] != D[i-1] {
			// pair A[l] & A[r], A[l] = -A[r]
			return false
		}
		// L - cnt * A[i] + cnt * (-A[i]) - R + (N - 2 * cnt) * A[i] = D[i]
		// R = -L
		// 2 * L - 2 * cnt * A[i] + (N - 2 * cnt) * A[i] = D[i]
		// (N - 4 * cnt) * A[i] = D[i] - L
		a := (D[i] - 2*L) / int64(N-2*cnt)
		if a <= 0 || a*int64(N-2*cnt) != (D[i]-2*L) {
			return false
		}
		L += a
		cnt++
	}
	return true
}