package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++{
		var n int
		fmt.Scan(&n)
		a := make([]int, n)
		for j := 0; j < n; j++{
			fmt.Scan(&a[j])
		}
		sort.Sort(sort.Reverse(sort.IntSlice(a)))
		for k := 0; k < len(a); k++{
			fmt.Print(a[k], " ")
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t, n int
	fmt.Fscan(reader, &t)
	for j := 0; j < t; j++ {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		sort.Ints(a)
		for i := n - 1; i >= 0; i-- {
			fmt.Fprintf(writer, "%d ", a[i])
		}
		fmt.Fprintln(writer)
	}
}//2020-07-31 14:14:22.768

package main

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

const INFINITY = math.MaxInt32/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	t := stdin.ReadInt()
	for i := 0; i < t; i++ {
		n := stdin.ReadInt()
		a := stdin.ReadIntSlice(n)
		sort.Sort(sort.Reverse(sort.IntSlice(a)))
		stdout.Println(strings.Join(ToStringSlice(a), " "))
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

func (s *Stdin) ReadIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt()
	}
	return a
}

func (s *Stdin) ReadStringSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = s.Read()
	}
	return a
}

func (s *Stdin) ReadFloat64Slice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadFloat64()
	}
	return a
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func IsPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}

func CeilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

func LCS(s, t string) string {
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	x := n
	y := m
	u := make([]byte, dp[n][m])
	i := dp[n][m] - 1
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			u[i] = s[x]
			i--
		}
	}

	return string(u)
}

// [0..n) から r個選んだ組合せを生成する。
// r < 0 の場合はすべての組合せを生成する。
func Combinations(n int, r int) [][]int {
	a := [][]int{}
	for i := uint(0); i < (1 << uint(n)); i++ {
		b := []int{}
		for j := uint(0); j < uint(n); j++ {
			if i&(uint(1)<<j) != 0 {
				b = append(b, int(j))
			}
		}

		if r < 0 || len(b) == r {
			a = append(a, b)
		}
	}
	return a
}

// [0..n)の順列を生成する。
func Permutations(n int) [][]int {
	type e struct {
		bit uint
		a   []int
	}

	q := []*e{}
	for i := 0; i < n; i++ {
		q = append(q, &e{bit: 1 << uint(i), a: []int{i}})
	}

	p := [][]int{}
	for x := 0; x < len(q); x++ {
		cur := q[x]
		if cur.bit == (1<<uint(n) - 1) {
			p = append(p, cur.a)
			continue
		}

		for i := 0; i < n; i++ {
			if cur.bit&(1<<uint(i)) != 0 {
				continue
			}

			m := len(cur.a) + 1
			b := make([]int, m)
			copy(b, cur.a)
			b[m-1] = i
			q = append(q, &e{bit: cur.bit | (1 << uint(i)), a: b})
		}
	}
	return p
}

func ReverseSlice(v interface{}) {
	if reflect.TypeOf(v).Kind() == reflect.Slice {
		slice := reflect.ValueOf(v)
		for i1, n := 0, slice.Len(); i1 < n/2; i1++ {
			i2 := n - i1 - 1
			v1 := reflect.ValueOf(slice.Index(i1).Interface())
			slice.Index(i1).Set(slice.Index(i2))
			slice.Index(i2).Set(v1)
		}
	}
}

func ReverseString(s string) string {
	t := []rune(s)
	ReverseSlice(t)
	return string(t)
}

func ToStringSlice(slice interface{}) []string {
	// 本来はerrを返却すべき。 利用する側(=自分)は引数がsliceであることを知っている。
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v is not slice", slice))
	}

	src := reflect.ValueOf(slice)
	n := src.Len()
	dst := make([]string, n)
	for i := 0; i < n; i++ {
		dst[i] = fmt.Sprintf("%v", src.Index(i))
	}
	return dst
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, n, x int
	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n)
		var a []int
		for i := 0; i < n; i ++ {
			Fscan(in, &x)
			a = append(a, x)
		}
		sort.Slice(a, func(i, j  int) bool {
			return a[i] > a[j]
		})
		for i := 0; i < n; i++ {
			Fprint(out, a[i])
			if (i == n-1) {
				Fprintln(out)
			} else {
				Fprint(out, " ")
			}
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, n, x int
	fmt.Fscanf(in, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(in, "%d\n", &n)
		var a []int
		for i := 0; i < n; i ++ {
			fmt.Fscanf(in, "%d", &x)
			if(i == n - 1) {
				fmt.Fscanf(in, "\n")
			} else {
				fmt.Fscanf(in, " ")
			}
			a = append(a, x)
		}
		sort.Sort(sort.Reverse(sort.IntSlice(a)))
		for i := 0; i < n; i++ {
			fmt.Fprintf(out, "%d", a[i])
			if(i == n - 1) {
				fmt.Fprintf(out,"\n")
			} else {
				fmt.Fprintf(out, " ")
			}
		}
	}
}

package main

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

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

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

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

package main

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

func main(){
	var t,n int
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)

	defer w.Flush()
	fmt.Fscanf(r,"%d\n",&t)

	for T := 0 ; T < t ; T ++ {
		fmt.Fscanf(r,"%d\n",&n)
		//fmt.Println("N = ",n)
		a := make([]int , n)

		for i := 0 ; i < n ; i ++ {
			fmt.Fscanf(r,"%d",&a[i])
		}
		fmt.Fscanf(r,"\n")
		sort.Slice(a, func (i,j int) bool {
			return a[i] > a[j]
		})

		for i := 0 ; i < n ; i ++ {
			fmt.Fprintf(w, "%d ", a[i])
		}
		fmt.Fprintf(w,"\n")

		//fmt.Println(a)
	}

}

package main

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

func main() {
	defer writer.Flush()

	var tests int
	Input(&tests)

	for t := 1; t <= tests; t++ {
		var n int
		Input(&n)

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

		sort.Ints(a)
		sort.Sort(sort.Reverse(sort.IntSlice(a)))

		for i := 0; i < n; i++ {
			Print(a[i], " ")
		}
		Print("\n")
	}
}

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

func Input(a ...interface{}) {
	_, _ = fmt.Fscan(reader, a...)
}

func Print(a ...interface{}) {
	_, _ = fmt.Fprint(writer, a...)
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		line = readLine(reader)
		ans := strings.Split(string(line), " ")
		an := make([]int, len(ans))
		for i := 0; i < n; i++ {
			an[i], _ = strconv.Atoi(ans[i])
		}
		sort.Ints(an)
		for i := n - 1; i >= 0; i-- {
			fmt.Printf("%d ", an[i])
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

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

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

	for t := 0; t < ts; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)

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

		sort.Ints(a)

		for i := len(a) - 1; i >= 0; i-- {
			fmt.Fprintf(w, "%d ", a[i])
		}
		fmt.Fprintf(w, "\n")
	}
}

package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		for n--; n >= 0; n-- {
			Fprint(out, a[n], " ")
		}
		Fprintln(out)
	}
}

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

package main

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

func main() {

	for testCase := ScanInt(); testCase > 0; testCase-- {
		count := ScanInt()
		givenArray := ScanIntSlice(count)

		sort.Slice(givenArray, func(i, j int) bool {
			return givenArray[i] > givenArray[j]
		})
		P(SArr(givenArray))
	}
	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

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

package main

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

func main() {
	for testCase := scanInt(); testCase > 0; testCase--{
		count := scanInt()
		givenArray := scanIntSlice(count)
		sort.Slice(givenArray, func(i, j int) bool {
			return givenArray[i] > givenArray[j]
		})
		printFmt(spaceSeperatedStringFromArray(givenArray))
	}
	close(channelType)
	oWg.Wait()
}

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

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}
func scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}
func scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + " ")}; return sb.String()}
func spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + " ")}; return sb.String()}
func minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }

package main

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		n:=ReadInt()
		var a []int
		for i:=1;i<=n;i++ {
			x:=ReadInt()
			a=append(a,x)
		}
		sort.Slice(a, func(i, j int) bool {
			return a[i]>a[j]
		})
		for _,i:=range a{
			fmt.Printf("%d ",i)
		}
		fmt.Println()
	}
}

////////////////////////////////////

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
}

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadInt64() int64 {
	intstr := ReadString()
	i, _ := strconv.ParseInt(intstr, 10, 64)
	return int64(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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

package main

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

func main() {
	for testCase := scanInt(); testCase > 0; testCase-- {
		count := scanInt()
		givenArray := scanIntSlice(count)
		for i := 0; i < count; i++ {
			for j := count - 1; j > 0; j-- {
				if i < j && j-givenArray[j] != i-givenArray[i] {
					givenArray[i], givenArray[j] = givenArray[j], givenArray[i]
				}
			}
		}
		printFmt(SArr(givenArray))
		//printFmt(givenArray)
	}
	close(channelType)
	oWg.Wait()
}

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

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string { in.Scan(); return in.Text() }
func scanInt() int       { i, _ := strconv.Atoi(scanString()); return i }
func scanInt64() int64   { i, _ := strconv.ParseInt(scanString(), 10, 64); return i }
func scanStringSlice(n int) []string {
	s := make([]string, n);
	for i := 0; i < n; i++ {
		s[i] = scanString()
	};
	return s
}
func scanIntSlice(n int) []int {
	arr := make([]int, n);
	for i := 0; i < n; i++ {
		arr[i] = scanInt()
	};
	return arr
}
func scanInt64Slice(n int) []int64 {
	arr := make([]int64, n);
	for i := 0; i < n; i++ {
		arr[i] = scanInt64()
	};
	return arr
}

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string { return fmt.Sprintf("%v", v) }
func spaceSeperatedStringFromArray(a []int) string {
	sb := strings.Builder{};
	sb.Grow(len(a) * 9);
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	};
	return sb.String()
}
func spaceSeperatedStringFromArray64(a []int64) string {
	sb := strings.Builder{};
	sb.Grow(len(a) * 9);
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	};
	return sb.String()
}
func minMaxFromArray(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64);
	for _, v := range args {
		if v < minVal {
			minVal = v
		};
		if v > maxVal {
			maxVal = v
		}
	};
	return minVal, maxVal
}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64         { return a / gcdCalculation(a, b) * b }
func gcdCalculation(a, b int64) int64 {
	if (a == 0) {
		return b
	};
	return gcdCalculation(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func absoluteValue(x int64) int64 {
	if x < 0 {
		return -x
	};
	return x
}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32);
	for _, v := range args {
		if v < minVal {
			minVal = v
		};
		if v > maxVal {
			maxVal = v
		}
	};
	return minVal, maxVal
}
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}

package main

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

func main() {
	for testCase := scanInt(); testCase > 0; testCase--{
		count := scanInt()
		givenArray := scanIntSlice(count)
		for i := 0; i < count; i++{
			for j := 0; j < count; j++{
				if j - givenArray[j] != i - givenArray[i] && i < j{
					givenArray[i], givenArray[j] = givenArray[j], givenArray[i]
				}
			}
		}
		//printFmt(spaceSeperatedStringFromArray(givenArray))
		printFmt(givenArray)
	}
	close(channelType)
	oWg.Wait()
}

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

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}
func scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}
func scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + " ")}; return sb.String()}
func spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + " ")}; return sb.String()}
func minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }

package main

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

func main() {
	for testCase := scanInt(); testCase > 0; testCase--{
		count := scanInt()
		givenArray := scanIntSlice(count)
		//answer := make([]int, count)
		for i := 0; i < count; i++{
			for j := 0; j < count; j++{
				if j - givenArray[j] != i - givenArray[i]{
					givenArray[i], givenArray[j] = givenArray[j], givenArray[i]
				}
			}
		}
		printFmt(spaceSeperatedStringFromArray(givenArray))
	}
	close(channelType)
	oWg.Wait()
}

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

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}
func scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}
func scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}

/*********************** Utils ***********************/

func stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + " ")}; return sb.String()}
func spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + " ")}; return sb.String()}
func minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) { minVal, maxVal := int(math.MaxInt32), int(math.MinInt32); for _, v := range args { if v < minVal { minVal = v }; if v > maxVal { maxVal = v } }; return minVal, maxVal }

package main

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		n:=ReadInt()
		var a []int
		for i:=1;i<=n;i++ {
			x:=ReadInt()
			a=append(a,x)
		}
		sort.Slice(a, func(i, j int) bool {
			return a[i]>a[j]
		})
		fmt.Println(a)
	}
}

////////////////////////////////////

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
}

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadInt64() int64 {
	intstr := ReadString()
	i, _ := strconv.ParseInt(intstr, 10, 64)
	return int64(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

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

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

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


package main

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

var nn int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 1
	//fmt.Fscanf(in, "%d\n", &q)
	for ii := 0; ii < q; ii++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}
		fmt.Fscanf(in, "\n")
		f := make([][]int, n)
		for i := 0; i < n; i++ {
			f[i] = make([]int, 31)
			for j := 0; j < 31; j++ {
				f[i][j] = -1000
			}
		}
		f[0][0] = 0
		if a[0] > 0 {
			f[0][a[0]] = 0
		}
		//fmt.Println(f[0])
		for i := 1; i < n; i++ {
			if a[i] > 0 {
				f[i][a[i]] = 0
			} else {
				f[i][0] = 0
			}
			for j := 0; j < 31; j++ {
				if f[i-1][j] != -1000 {
					if a[i] > j {
						f[i][a[i]] = max(f[i][a[i]], f[i-1][j]+j)
					} else {
						f[i][j] = max(f[i][j], f[i-1][j]+a[i])
					}
				}
			}
			//fmt.Println(f[i])
		}
		ans := 0
		for i := 0; i < n; i++ {
			for j := 0; j < 31; j++ {
				if f[i][j] > ans {
					ans = f[i][j]
				}
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1359D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, ans int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}
	for mx := 1; mx <= 30; mx++ {
		i := 0
		for {
			for ; i < n && a[i] > mx; i++ {
			}
			if i == n {
				break
			}
			s, mxS := a[i], a[i]
			for i++; i < n && a[i] <= mx; i++ {
				s = max(s+a[i], a[i])
				mxS = max(mxS, s)
			}
			ans = max(ans, mxS-mx)
		}
	}
	Fprint(out, ans)
}

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

package main

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

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

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

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

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

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

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

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

	return i
}

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

	n := readNum(reader)
	A := readNNums(reader, n)

	fmt.Println(solve(n, A))
}

const INF = math.MaxInt32 >> 1
const N_INF = -INF

func solve(n int, A []int) int {
	var ans int64
	for mx := int64(0); mx < 31; mx++ {
		var cur int64
		var best int64

		for i := 0; i < n; i++ {
			v := int64(A[i])
			if v > mx {
				v = N_INF
			}
			cur += v
			if cur < best {
				best = cur
			}
			if cur-best-mx > ans {
				ans = cur - best - mx
			}
		}
	}

	return int(ans)
}

func solve1(n int, A []int) int {
	N := n + 1
	arr := make([]int, 2*N)

	reset := func() {
		for i := 0; i < len(arr); i++ {
			arr[i] = INF
		}
	}

	reset()

	update := func(p int, v int) {
		p += N
		arr[p] = v
		for p > 1 {
			arr[p>>1] = min(arr[p], arr[p^1])
			p >>= 1
		}
	}

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

		l += N
		r += N

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

	stack := make([]int, n)
	var p int

	left := make([]int, n)
	var sum int
	update(0, sum)
	for i := 0; i < n; i++ {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}
		var j = 0
		if p > 0 {
			j = stack[p-1] + 1
		}
		sum += A[i]
		update(i+1, sum)
		left[i] = sum - get(j, i+1)
		stack[p] = i
		p++
	}

	reset()

	sum = 0
	p = 0
	var best = 0
	update(0, sum)
	// i + j == n
	for i := n - 1; i >= 0; i-- {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}

		sum += A[i]
		update(n-i, sum)

		var j = 0
		if p > 0 {
			j = n - stack[p-1] + 1
		}
		tmp := sum - get(j, n-i)

		if tmp+left[i]-2*A[i] > best {
			best = tmp + left[i] - 2*A[i]
		}
		stack[p] = i
		p++
	}

	return best
}

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"
	"math"
	"os"
)

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

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

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

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

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

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

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

	return i
}

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

	n := readNum(reader)
	A := readNNums(reader, n)

	fmt.Println(solve(n, A))
}

const INF = math.MaxInt32 >> 1

func solve(n int, A []int) int {
	N := n + 1
	arr := make([]int, 2*N)

	reset := func() {
		for i := 0; i < len(arr); i++ {
			arr[i] = INF
		}
	}

	reset()

	update := func(p int, v int) {
		p += N
		arr[p] = v
		for p > 1 {
			arr[p>>1] = min(arr[p], arr[p^1])
			p >>= 1
		}
	}

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

		l += N
		r += N

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

	stack := make([]int, n)
	var p int

	left := make([]int, n)
	var sum int
	update(0, sum)
	for i := 0; i < n; i++ {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}
		var j = 0
		if p > 0 {
			j = stack[p-1] + 1
		}
		sum += A[i]
		update(i+1, sum)
		left[i] = sum - get(j, i+1)
		stack[p] = i
		p++
	}

	reset()

	sum = 0
	p = 0
	var best = 0
	update(0, sum)
	// i + j == n
	for i := n - 1; i >= 0; i-- {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}

		sum += A[i]
		update(n-i, sum)

		var j = 0
		if p > 0 {
			j = n - stack[p-1] + 1
		}
		tmp := sum - get(j, n-i)

		if tmp+left[i]-2*A[i] > best {
			best = tmp + left[i] - 2*A[i]
		}
		stack[p] = i
		p++
	}

	return best
}

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"
	"math"
	"os"
)

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

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

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

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

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

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

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

	return i
}

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

	n := readNum(reader)
	A := readNNums(reader, n)

	fmt.Println(solve(n, A))
}

const INF = math.MaxInt32 >> 1
const N_INF = -INF

func solve(n int, A []int) int {
	var ans int64
	for mx := int64(0); mx < 31; mx++ {
		var cur int64
		var best int64

		for i := 0; i < n; i++ {
			v := int64(A[i])
			if v > mx {
				v = N_INF
			}
			cur += v
			if cur > best {
				best = cur
			}
			if cur < 0 {
				cur = 0
			}
		}

		if best-mx > ans {
			ans = best - mx
		}
	}

	return int(ans)
}

func solve2(n int, A []int) int {
	var ans int64
	for mx := int64(0); mx < 31; mx++ {
		var cur int64
		var best int64

		for i := 0; i < n; i++ {
			v := int64(A[i])
			if v > mx {
				v = N_INF
			}
			cur += v
			if cur < best {
				best = cur
			}
			if cur-best-mx > ans {
				ans = cur - best - mx
			}
		}
	}

	return int(ans)
}

func solve1(n int, A []int) int {
	N := n + 1
	arr := make([]int, 2*N)

	reset := func() {
		for i := 0; i < len(arr); i++ {
			arr[i] = INF
		}
	}

	reset()

	update := func(p int, v int) {
		p += N
		arr[p] = v
		for p > 1 {
			arr[p>>1] = min(arr[p], arr[p^1])
			p >>= 1
		}
	}

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

		l += N
		r += N

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

	stack := make([]int, n)
	var p int

	left := make([]int, n)
	var sum int
	update(0, sum)
	for i := 0; i < n; i++ {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}
		var j = 0
		if p > 0 {
			j = stack[p-1] + 1
		}
		sum += A[i]
		update(i+1, sum)
		left[i] = sum - get(j, i+1)
		stack[p] = i
		p++
	}

	reset()

	sum = 0
	p = 0
	var best = 0
	update(0, sum)
	// i + j == n
	for i := n - 1; i >= 0; i-- {
		for p > 0 && A[stack[p-1]] <= A[i] {
			p--
		}

		sum += A[i]
		update(n-i, sum)

		var j = 0
		if p > 0 {
			j = n - stack[p-1] + 1
		}
		tmp := sum - get(j, n-i)

		if tmp+left[i]-2*A[i] > best {
			best = tmp + left[i] - 2*A[i]
		}
		stack[p] = i
		p++
	}

	return best
}

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"
)

// github.com/EndlessCheng/codeforces-go
type seg []struct {l, r, todo, mx, mi int; s int64}

func (t seg) maintain(o int) {
	l, r := t[o<<1], t[o<<1|1]
	t[o].mx = l.mx
	t[o].mi = r.mi
	t[o].s = l.s + r.s
}

func (t seg) build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].mx = a[l-1]
		t[o].mi = a[l-1]
		t[o].s = int64(a[l-1])
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

func (t seg) do(O, v int) {
	o := &t[O]
	o.todo = v
	o.mx = v
	o.mi = v
	o.s = int64(o.r-o.l+1) * int64(v)
}

func (t seg) spread(o int) {
	if v := t[o].todo; v > 0 {
		t.do(o<<1, v)
		t.do(o<<1|1, v)
		t[o].todo = 0
	}
}

func (t seg) update(o, r, v int) {
	if t[o].l > r || v <= t[o].mi {
		return
	}
	if t[o].r <= r && v >= t[o].mx {
		t.do(o, v)
		return
	}
	t.spread(o)
	t.update(o<<1, r, v)
	t.update(o<<1|1, r, v)
	t.maintain(o)
}

func (t seg) query(o, l int, v *int64) int {
	if t[o].r < l || *v < int64(t[o].mi) {
		return 0
	}
	if l <= t[o].l && *v >= t[o].s {
		*v -= t[o].s
		return t[o].r - t[o].l + 1
	}
	t.spread(o)
	return t.query(o<<1, l, v) + t.query(o<<1|1, l, v)
}

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

	var n, q, tp, p, v int
	Fscan(in, &n, &q)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	t := make(seg, 4*n)
	t.build(a, 1, 1, n)
	for ; q > 0; q-- {
		if Fscan(in, &tp, &p, &v); tp == 1 {
			t.update(1, p, v)
		} else {
			v := int64(v)
			Fprintln(out, t.query(1, p, &v))
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
type seg []struct {
	l, r, todo, max, min int
	sum                  int64
}

func (t seg) maintain(o int) {
	l, r := t[o<<1], t[o<<1|1]
	t[o].max = l.max
	t[o].min = r.min
	t[o].sum = l.sum + r.sum
}

func (t seg) build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].max = a[l-1]
		t[o].min = a[l-1]
		t[o].sum = int64(a[l-1])
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

func (t seg) do(O, v int) {
	o := &t[O]
	o.todo = v
	o.max = v
	o.min = v
	o.sum = int64(o.r-o.l+1) * int64(v)
}

func (t seg) spread(o int) {
	if v := t[o].todo; v > 0 {
		t.do(o<<1, v)
		t.do(o<<1|1, v)
		t[o].todo = 0
	}
}

func (t seg) update(o, r, v int) {
	if v <= t[o].min {
		return
	}
	if t[o].r <= r && v >= t[o].max {
		t.do(o, v)
		return
	}
	t.spread(o)
	t.update(o<<1, r, v)
	if (t[o].l+t[o].r)>>1 < r {
		t.update(o<<1|1, r, v)
	}
	t.maintain(o)
}

func (t seg) query(o, l int, v *int64) int {
	if *v < int64(t[o].min) {
		return 0
	}
	if l <= t[o].l && *v >= t[o].sum {
		*v -= t[o].sum
		return t[o].r - t[o].l + 1
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l > m {
		return t.query(o<<1|1, l, v)
	}
	vl := t.query(o<<1, l, v)
	vr := t.query(o<<1|1, l, v)
	return vl + vr
}

func CF1439C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, q, tp, p, v int
	Fscan(in, &n, &q)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	t := make(seg, 4*n)
	t.build(a, 1, 1, n)
	for ; q > 0; q-- {
		if Fscan(in, &tp, &p, &v); tp == 1 {
			t.update(1, p, v)
		} else {
			v := int64(v)
			Fprintln(out, t.query(1, p, &v))
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
type seg []struct {
	l, r, todo, min int
	sum             int64
}

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

func (t seg) maintain(o int) {
	l, r := t[o<<1], t[o<<1|1]
	t[o].min = min(l.min, r.min)
	t[o].sum = l.sum + r.sum
}

func (t seg) build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].min = a[l-1]
		t[o].sum = int64(a[l-1])
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

func (t seg) do(O, v int) {
	o := &t[O]
	o.min = v
	o.sum = int64(o.r-o.l+1) * int64(v)
}

func (t seg) spread(o int) {
	if v := t[o].todo; v != 0 {
		t.do(o<<1, v)
		t.do(o<<1|1, v)
		t[o].todo = 0
	}
}

func (t seg) update(o, l, r, v int) {
	if v <= t[o].min {
		return
	}
	if l <= t[o].l && t[o].r <= r {
		t.do(o, v)
		return
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		t.update(o<<1, l, r, v)
	}
	if m < r {
		t.update(o<<1|1, l, r, v)
	}
	t.maintain(o)
}

func (t seg) query(o, l int, v *int64) int {
	if *v < int64(t[o].min) {
		return 0
	}
	if l <= t[o].l && *v >= t[o].sum {
		*v -= t[o].sum
		return t[o].r - t[o].l + 1
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l > m {
		return t.query(o<<1|1, l, v)
	}
	vl := t.query(o<<1, l, v)
	vr := t.query(o<<1|1, l, v)
	return vl + vr
}

func CF1439C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, q, tp, p, v int
	Fscan(in, &n, &q)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	t := make(seg, 4*len(a))
	t.build(a, 1, 1, len(a))
	for ; q > 0; q-- {
		if Fscan(in, &tp, &p, &v); tp == 1 {
			t.update(1, 1, p, v)
		} else {
			v := int64(v)
			Fprintln(out, t.query(1, p, &v))
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
type seg []struct {
	l, r, todo, min int
	sum             int64
}

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

func (t seg) maintain(o int) {
	l, r := t[o<<1], t[o<<1|1]
	t[o].min = min(l.min, r.min)
	t[o].sum = l.sum + r.sum
}

func (t seg) build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].min = a[l-1]
		t[o].sum = int64(a[l-1])
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

func (t seg) do(O, v int) {
	o := &t[O]
	o.todo = v
	o.min = v
	o.sum = int64(o.r-o.l+1) * int64(v)
}

func (t seg) spread(o int) {
	if v := t[o].todo; v != 0 {
		t.do(o<<1, v)
		t.do(o<<1|1, v)
		t[o].todo = 0
	}
}

func (t seg) update(o, r, v int) {
	if v <= t[o].min {
		return
	}
	if t[o].r <= r {
		t.do(o, v)
		return
	}
	t.spread(o)
	t.update(o<<1, r, v)
	if (t[o].l+t[o].r)>>1 < r {
		t.update(o<<1|1, r, v)
	}
	t.maintain(o)
}

func (t seg) query(o, l int, v *int64) int {
	if *v < int64(t[o].min) {
		return 0
	}
	if l <= t[o].l && *v >= t[o].sum {
		*v -= t[o].sum
		return t[o].r - t[o].l + 1
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l > m {
		return t.query(o<<1|1, l, v)
	}
	vl := t.query(o<<1, l, v)
	vr := t.query(o<<1|1, l, v)
	return vl + vr
}

func CF1439C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, q, tp, p, v int
	Fscan(in, &n, &q)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	t := make(seg, 4*n)
	t.build(a, 1, 1, n)
	for ; q > 0; q-- {
		if Fscan(in, &tp, &p, &v); tp == 1 {
			t.update(1, p, v)
		} else {
			v := int64(v)
			Fprintln(out, t.query(1, p, &v))
		}
	}
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1010B() {
	var m, n, t int
	Scan(&m, &n)
	a := make([]bool, n)
	for i := range a {
		Println(1)
		Scan(&t)
		if t == 0 {
			return
		}
		a[i] = t == 1
	}
	cnt := 0
	sort.Search(m+1, func(x int) bool {
		if x == 0 {
			return false
		}
		Println(x)
		Scan(&t)
		if t == 0 {
			os.Exit(0)
		}
		if !a[cnt%n] {
			t = -t
		}
		cnt++
		return t == -1
	})
}

func main() { CF1010B() }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	truthT := make([]bool, m)
	for i := 0; i < m; i++ {
		fmt.Fprintf(out, "%d\n", 1)
		out.Flush()
		res := 0
		fmt.Fscanf(in, "%d\n", &res)
		if res == 0 {
			return
		}
		if res == 1 {
			truthT[i] = true
		} else {
			truthT[i] = false
		}
	}
	l := 1
	r := n
	for i := 0; i < 600; i++ {
		mid := (l + r) / 2
		fmt.Fprintf(out, "%d\n", mid)
		out.Flush()
		res := 0
		fmt.Fscanf(in, "%d\n", &res)
		if res == 0 {
			return
		}
		if !truthT[i%m] {
			res = -res
		}
		if res == 1 {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1010B() {
	var m, n, res, ans int
	Scan(&m, &n)
	a := make([]bool, n)
	for i := range a {
		Println(0)
		Scan(&res)
		a[i] = res == 1
	}
	cnt := 0
	sort.Search(m+1, func(x int) bool {
		if x == 0 {
			return false
		}
		if ans > 0 {
			return x >= ans
		}
		Println(x)
		Scan(&res)
		if res == 0 {
			os.Exit(0)
		}
		if !a[cnt%n] {
			res = -res
		}
		cnt++
		return res == -1
	})
}

func main() { CF1010B() }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1010B() {
	var m, n, t int
	Scan(&m, &n)
	a := make([]bool, n)
	for i := range a {
		Println(-1)
		Scan(&t)
		a[i] = t == 1
	}
	cnt := 0
	sort.Search(m+1, func(x int) bool {
		if x == 0 {
			return false
		}
		Println(x)
		Scan(&t)
		if t == 0 {
			os.Exit(0)
		}
		if !a[cnt%n] {
			t = -t
		}
		cnt++
		return t == -1
	})
}

func main() { CF1010B() }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	truthT := make([]bool, m)
	for i := 0; i < m; i++ {
		fmt.Fprintf(out, "%d\n", 1)
		out.Flush()
		res := 0
		fmt.Fscanf(in, "%d\n", &res)
		if res == 0 {
			return
		}
		if res == 1 {
			truthT[i] = true
		} else {
			truthT[i] = false
		}
	}
	l := 1
	r := n
	for i := 0; i < m; i++ {
		mid := (l + r) / 2
		fmt.Fprintf(out, "%d\n", mid)
		out.Flush()
		res := 0
		fmt.Fscanf(in, "%d\n", &res)
		if res == 0 {
			return
		}
		if !truthT[i] {
			res = -res
		}
		if res == 1 {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return
}


package main
import "fmt"
func main(){
	var t int;
	fmt.Scanln(&t)
	for ;t >0;t-- {
	var n,k int;
	fmt.Scanln(&n,&k);
	if  n > k {
		if n%k == 0 {
		fmt.Println(1);
		} else {
		fmt.Println(2);
		}
	} else {
		if k%n == 0 {
		fmt.Println((k/n));
		}else {
		fmt.Println((k/n + 1));
		}
	}
	}
	// your code goes here
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	arr := make([][]int, t)
	for i := range arr {
		num := make([]int, 2)
		fmt.Scanf("%d %d\n", &num[0], &num[1])
		arr[i] = num
	}

	for _, v := range arr {
		fmt.Println(helper(v[0], v[1]))
	}
}

func helper(n, k int) int {
	if n%k == 0 {
		return 1
	}
	if n < k {
		if k%n == 0 {
			return k / n
		}
		return k/n + 1
	} else {
		m := n/k + 1
		return helper(n, m*k)
	}
}

package main

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

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

func solve(n, k int) int {
	if k < n {
		if n%k == 0 {
			return 1
		}
		return 2
	}
	if k%n == 0 {
		return k / n
	}
	return 1 + k/n
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &k)
		fmt.Println(solve(n, k))
	}
}

package main

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

	//"math"
	"os"
)

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

	truth := make(map[bool]int)
	truth[false] = 0; truth[true] = 1
	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int64
		Fscan(in, &n, &k)

		multiplier := sort.Search(int(n), func(i int) bool {
			return int64(i) * k >= n
		})
		Fprintln(out, k * int64(multiplier) / n + int64(truth[k * int64(multiplier) % n != 0]))
	}
}

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

package main

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

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

	truth := make(map[bool]int)
	truth[false] = 0; truth[true] = 1
	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int64
		Fscan(in, &n, &k)

		left, right := int64(1), n
		for left < right {
			mid := left + ((right - left) >> 1)
			if mid * k >= n {
				right = mid
			} else {
				left = mid + 1
			}
		}
		//Fprintln(out, "left = ", left)
		Fprintln(out, k * left / n + int64(truth[k * left % n != 0]))
	}
}

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

package main

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

func solve(n, k int) int {
	if 1 == k {
		return 1
	}
	if n > k {
		if 0 == n % k {
			return 1
		} else {
			return 2
		}
	}
	return int(math.Ceil(float64(k) / float64(n)))
}

func main() {
	var (
		in = bufio.NewReader(os.Stdin)
		out = bufio.NewWriter(os.Stdout)
		t, n, k int
	)
	defer out.Flush()
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		fmt.Fprintln(out, solve(n, k))
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		var n, k, ans int
		fmt.Scan(&n, &k)
		if k >= n {
			ans = 1
			k -= n
			ans += k / n
			if k%n != 0 {
				ans++
			}
		} else {
			if n%k != 0 {
				ans = 2
			} else {
				ans = 1
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
)

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

	for ; T > 0; T-- {
		var n, k int
		fmt.Scan(&n, &k)

		if k >= n {
			fmt.Println((k + n - 1) / n)
		} else {
			if n % k == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	result := make([]string, t)
	for i := 0; i < t; i++ {
		var n int64
		var k int64
		scanf("%d %d\n", &n, &k)
		result[i] = strconv.FormatInt(solve(n, k), 10)
	}
	printf("%v", strings.Join(result, "\n"))
}

func solve(n int64, k int64) int64 {
	if k < n {
		if n % k == 0 {
			return 1
		}
		return 2
	}
	if k % n == 0 {
		return k / n
	}
	return k / n + 1
}

package main

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

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

func main() {
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, k int
		fmt.Fscan(in, &n, &k)
		if n > k {
			if n%k == 0 {
				fmt.Fprintln(out, 1)
			} else {
				fmt.Fprintln(out, 2)
			}
		} else {
			fmt.Fprintln(out, (k-1)/n+1)
		}
	}
	out.Flush()
}

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		if k == 1 {
			fmt.Println(1)
		} else if n > k {
			if n%k == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		} else if k%n == 0 {
			fmt.Println(k / n)
		} else {
			fmt.Println(k/n + 1)
		}
	}
}

package main

import "fmt"

func main() {
    //fmt.Println("hello world")
    var t int
    fmt.Scanln(&t)

    for i := 0; i < t; i++ {
        var n,k int64
        fmt.Scan(&n)
        fmt.Scan(&k)
        med := ((n + k - 1) / k)
        ans := (k*med)
        fmt.Println((ans + n - 1) / n)
    }

    // fmt.Scanln(&n)
    // fmt.Scanln(&k)
    // fmt.Println(k)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var test int
	fmt.Scanln(&test)

	for t := 0; t < test; t++ {
		var n, k float64
		fmt.Scanln(&n, &k)

		if n > k {
			k = k * math.Ceil(n/k)
		}

		fmt.Println(int(math.Ceil(k / n)))
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t != 0; t-- {
		var n, k int
		fmt.Scan(&n, &k)
		if n > k {
			if n%k == 0 {
				fmt.Println("1")
			} else {
				fmt.Println("2")
			}
		} else {
			var ans = k / n
			if k%n != 0 {
				ans++
			}
			fmt.Println(ans)
		}
	}
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    // (k - m % k) % k
    fmt.Fprintln(output, (n + (k - n%k)%k - 1) / n + 1)
}

package main

import (
	"fmt"
)

func main() {

	var tcs int
	_, _ = fmt.Scan(&tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, k int64
		_, _ = fmt.Scan(&n, &k)

		if k < n {
			k *= (k + n - 1) / k
		}

		ans := (n + k - 1) / n

		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		n, k := scanInt(), scanInt()

		if n%k == 0 {
			fmt.Println(1)
		} else {
			diff := k - n%k

			if diff%n == 0 {
				fmt.Println(1 + diff/n)
			} else {
				fmt.Println(2 + diff/n)
			}
		}
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, k := readTwoNums(reader)
		res := solve(n, k)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	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, k int) int {
	if n < k {
		return (k + n - 1) / n
	}
	if n == k {
		return 1
	}
	// n > k
	// n * a + m [m < n] == k * b
	// a = (k * b - m) / n
	// k * b >= n
	b := n / k
	if b*k < n {
		b++
	}
	a := b * k / n
	if a*n < b*k {
		a++
	}
	return a
}

package main

import "fmt"

func main() {
	var T int64
	fmt.Scan(&T)
	for ; T > 0; T-- {
		var n, k int64
		fmt.Scan(&n, &k)

		if n > k {
			x := n / k
			if n%k > 0 {
				x++
			}
			k = x * k
		}
		if k%n == 0 {
			fmt.Println(k / n)
		} else {
			fmt.Println(k/n + 1)
		}
	}

}

package main
import "fmt"

func main(){
	// your code goes here
	var kase, n, k int
	fmt.Scan(&kase)
	for kase>0 {
		fmt.Scan(&n, &k)
		if n>=k{
			if n%k == 0{
				fmt.Println("1");
			}else{
				fmt.Println("2");
			}
		}else{
		fmt.Println((k+n-1)/n)}
		kase--
	}
}

package main

import (
	. "fmt"
)

func main(){
	var t int;
	Scan(&t);
	for i:=0;i<t;i++ {
		var n, k int
		Scan(&n);
		Scan(&k);
		if n >= k {
			if n%k == 0 {
				Println("1");
			} else{
				Println("2");
			}
		} else{
			if k%n == 0 {
				Println(k/n);
			} else{
				Println(k/n+1);
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	//"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() {
	defer writer.Flush()
	//RedirectInputToFile(reader, "input.txt")
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		var (
			n, k int64
		)
		scan(&n)
		scan(&k)

		solve(n, k)
	}
}

func solve(n int64, k int64) {
	s := (n + k - 1) / k
	printf("%v\n", (s*k+n-1)/n)
}

package main

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

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

func MAX(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 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
		}
	}
}

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

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

		if k == n {
			fmt.Println(1)
		} else {
			if k > n {
				if k%n == 0 {
					fmt.Println(k / n)
				} else {
					s := k % n
					fmt.Println((k-s)/n + 1)
				}
			}
			if k < n {
				if n%k == 0 {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}

	}

}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var n,k int
		Fscan(in, &n,&k)
		if n>=k {
			if n%k==0 {
				Fprintln(out, 1)
			} else {
				Fprintln(out, 2)
			}
		} else {
			Fprintln(out, (k-1)/n+1)
		}
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if k < n {
			if n%k == 0 {
				k = n
			} else {
				k = (n/k + 1) * k
			}
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import (
	"fmt"
)

func solve() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var n, k int
		fmt.Scan(&n)
		fmt.Scan(&k)
		var s int
		if n <= k {
			s = k
		} else {
			if n%k == 0 {
				s = n
			} else {
				s = (n/k + 1) * k
			}
		}
		var ans int
		if s%n == 0 {
			ans = s / n
		} else {
			ans = s/n + 1
		}
		fmt.Println(ans)
	}
}

func main() {
	// if _, ok := os.LookupEnv("ONLINE_JUDGE"); !ok {
	// 	os.Stdin, _ = os.OpenFile("1.in",
	// 		os.O_RDONLY, 0666)
	// }
	solve()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int
	k   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

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

		fmt.Fprintln(out, solve(n, k))

	}

}

func solve(n int, k int) int64 {

	i := 1

	if k*i < n {

		i = int(math.Ceil(float64(n) / float64(k)))

	}

	return int64(math.Ceil(float64(k*i) / float64(n)))

}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

func solve() {
	var n, k int
	fmt.Fscan(input, &n, &k)

	if n%k == 0 {
		fmt.Fprintln(output, "1")
		return
	}

	if k > n {
		ans := k / n
		if k%n > 0 {
			ans++
		}
		fmt.Fprintln(output, ans)
		return
	}

	qq := n + (n % k)
	ans := qq / n
	if qq%n > 0 {
		ans++
	}

	fmt.Fprintln(output, ans)
}

func main() {
	fmt.Fscan(input, &t)

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

	defer output.Flush()
}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

func solve() {
	var n, k int64
	fmt.Fscan(input, &n, &k)

	if n%k == 0 {
		fmt.Fprintln(output, "1")
		return
	}

	if k > n {
		ans := k / n
		if k%n > 0 {
			ans++
		}
		fmt.Fprintln(output, ans)
		return
	}

	qq := n + (n % k)
	ans := qq / n
	if qq%n > 0 {
		ans++
	}

	fmt.Fprintln(output, ans)
}

func main() {
	fmt.Fscan(input, &t)

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

	defer output.Flush()
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k == 1 || n == k {
        fmt.Fprintln(output, 1)
        return
    }
    if n > k {
        fmt.Fprintln(output, 2)
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k == 1 {
        fmt.Fprintln(output, 1)
        return
    }
    if n > k {
        fmt.Fprintln(output, 2)
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if n > k {
        if n%k == 0 {
            fmt.Fprintln(output, k)
        } else {
            fmt.Fprintln(output, n / k + 1 )
        }
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if n > k {
        if n%k == 0 {
            fmt.Fprintln(output, k)
        } else {
            fmt.Fprintln(output, (n - 1) / k + 1 )
        }
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if n > k {
        fmt.Fprintln(output, (n - k - 1)/k + 2)
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

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

func lcm(a, b int) int {
    return a * b / gcd(a, b)
}

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if n > k {
        fmt.Fprintln(output, lcm(k, n) / n)
    } else {
        fmt.Fprintln(output, (k - 1)/n + 1)
    }
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k == 1 {
        fmt.Fprintln(output, k)
        return
    }
    if n > k {
        fmt.Fprintln(output, (n - 1)/k + 1)
        return
    }
    fmt.Fprintln(output, (k - 1)/n + 1)
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k == 1 {
        fmt.Fprintln(output, k)
        return
    }
    if n > k {
        fmt.Fprintln(output, (n - 1)/k + 1)
        return
    }
    a := (k / n)
    if k % n > 0 { a++ }
    fmt.Fprintln(output, a)
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k == 1 {
        fmt.Fprintln(output, k)
        return
    }
    if n > k {
        fmt.Fprintln(output, n/k + 1)
        return
    }
    a := (k / n)
    if k % n > 0 { a++ }
    fmt.Fprintln(output, a)
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if n > k {
        fmt.Fprintln(output, (n - 1) / k + 1)
        return
    }
    a := (k / n)
    if k % n > 0 { a++ }
    fmt.Fprintln(output, a)
}

package main

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

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

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

func solve() {
    var (
        n, k int
    )
    fmt.Fscan(input, &n, &k)
    if k < n {
        fmt.Fprintln(output, 2)
        return
    }
    ans := k / n
    if k % n > 0 { ans++}
    fmt.Fprintln(output, ans)
    return

    a := make([]int64, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    fmt.Fprintln(output, ans)
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if cases == 992 && i == 97 {
			fmt.Println(n)
			fmt.Println(k)
			continue
		}
		if cases == 992 {
			continue
		}

		if k == 1 {
			fmt.Println(1)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if cases == 998 && i == 97 {
			fmt.Println(n)
			fmt.Println(k)
			continue
		}
		if cases == 998 {
			continue
		}

		if k == 1 {
			fmt.Println(1)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if cases == 998 && i == 97 {
			fmt.Println(n)
			fmt.Println(k)
		}
		if cases == 998 {
			continue
		}

		if k == 1 {
			fmt.Println(1)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if cases == 998 && i == 97 {
			fmt.Println(n)
			fmt.Println(k)
		}

		if k == 1 {
			fmt.Println(1)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if k == 1 {
			fmt.Println(1)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if k == 1 {
			fmt.Println(n)
			continue
		}

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import "fmt"

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

	for i := 0; i < cases; i++ {
		var n, k int
		fmt.Scan(&n, &k)

		if k < n {
			k = (n/k + 1) * k
		}

		var result int = (k / n)
		if k%n != 0 {
			result += 1
		}
		fmt.Println(result)
	}
}

package main

import (
	"fmt"
	"os"
)

func solve() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var n, k int
		fmt.Scan(&n)
		fmt.Scan(&k)
		var s int
		if n <= k {
			s = k
		} else {
			if n%k == 0 {
				s = n
			} else {
				s = (n/k + 1) * k
			}
		}
		var ans int
		if s%n == 0 {
			ans = s / n
		} else {
			ans = s/n + 1
		}
		fmt.Println(ans)
	}
}

func main() {
	if judge, _ := os.LookupEnv("ONLINE_JUDGE"); judge == "" {
		os.Stdin, _ = os.OpenFile("1.in", os.O_RDONLY, 0666)
	}
	solve()
}

package main

import (
	"fmt"
	"os"
)

func solve() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		var n, k int
		fmt.Scan(&n)
		fmt.Scan(&k)
		var s int
		if n <= k {
			s = k
		} else {
			if n%k == 0 {
				s = n
			} else {
				s = (n/k + 1) * k
			}
		}
		var ans int
		if s%n == 0 {
			ans = s / n
		} else {
			ans = s/n + 1
		}
		fmt.Println(ans)
	}
}

func main() {
	if _, ok := os.LookupEnv("ONLINE_JUDGE"); !ok {
		os.Stdin, _ = os.OpenFile("1.in",
			os.O_RDONLY, 0666)
	}
	solve()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int
	k   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

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

		fmt.Fprintln(out, solve(n, k))

	}

}

func solve(n int, k int) float64 {

	i := 1

	if k*i < n {

		i = int(math.Ceil(float64(n) / float64(k)))

	}

	return math.Ceil(float64(k*i) / float64(n))

}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int
	k   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

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

		fmt.Fprintln(out, solve(n, k))

	}

}

func solve(n int, k int) float64 {

	if k >= n {
		return math.Ceil(float64(k) / float64(n))
	} else {
		return math.Ceil(float64(n) / float64(k))
	}

}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

func solve() {
	var n, k int64
	fmt.Fscan(input, &n, &k)

	if n%k == 0 {
		fmt.Fprintln(output, "1")
		return
	}

	if k > n {
		ans := k / n
		if k%n > 0 {
			ans++
		}
		fmt.Fprintln(output, ans)
		return
	}

	ans := (2 * k) / n
	if (2*k)%n > 0 {
		ans++
	}

	fmt.Fprintln(output, ans)

}

func main() {
	fmt.Fscan(input, &t)

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

	defer output.Flush()
}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

func solve() {
	var n, k int64
	fmt.Fscan(input, &n, &k)

	if n%k == 0 {
		fmt.Fprintln(output, "1")
		return
	}

	if k > n {
		ans := k / n
		ans += (k % n)
		fmt.Fprintln(output, ans)
		return
	}

	ans := (2 * k) / n
	if (2*k)%n > 0 {
		ans++
	}

	fmt.Fprintln(output, ans)

}

func main() {
	fmt.Fscan(input, &t)

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

	defer output.Flush()
}

package main

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

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

func solve(n, k int) int {
	if k == 1 {
		return 1
	}
	if n > k {
		return 2
	}
	if k%n == 0 {
		return k / n
	}
	return 1 + k/n
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &k)
		fmt.Println(solve(n, k))
	}
}

package main

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

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

func solve(n, k int) int {
	if n > k {
		return 2
	}
	if k%n == 0 {
		return k / n
	}
	return 1 + k/n
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &k)
		fmt.Println(solve(n, k))
	}
}

package main

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

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

	truth := make(map[bool]int)
	truth[false] = 0; truth[true] = 1
	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n, k int
		Fscan(in, &n, &k)

		left, right := 1, n
		for left < right {
			mid := left + ((right - left) >> 1)
			if mid * k >= n {
				right = mid
			} else {
				left = mid + 1
			}
		}
		//Fprintln(out, "left = ", left)
		Fprintln(out, k * left / n + truth[k * left % n != 0])
	}
}

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

package main

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

func solve(n, k int) int {
	if 1 == k {
		return 1
	}
	if n > k {
		return 2
	}
	return int(math.Ceil(float64(k) / float64(n)))
}

func main() {
	var (
		in = bufio.NewReader(os.Stdin)
		out = bufio.NewWriter(os.Stdout)
		t, n, k int
	)
	defer out.Flush()
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		fmt.Fprintln(out, solve(n, k))
	}
}

package main

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

func solve(n, k int) int {
	if n > k {
		return 2
	}
	return int(math.Ceil(float64(k) / float64(n)))
}

func main() {
	var (
		in = bufio.NewReader(os.Stdin)
		out = bufio.NewWriter(os.Stdout)
		t, n, k int
	)
	defer out.Flush()
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		fmt.Fprintln(out, solve(n, k))
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		var n, k, ans int
		fmt.Scan(&n, &k)
		if k >= n {
			ans = 1
			k -= n
			ans += k / n
			if k%n != 0 {
				ans++
			}
		} else {
			ans = 2
		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
)

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

package main

import (
	"fmt"
)

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

	for ; T > 0; T-- {
		var n, k int
		fmt.Scan(&n, &k)

		if k >= n {
			fmt.Println((k + n - 1) / n)
		} else {
			if k%n == 0 {
				fmt.Println(k / n)
			} else {
				fmt.Println(k/n + 1)
			}
		}
	}
}

package main

import (
	"fmt"
)

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

	for ; T > 0; T-- {
		var n, k int
		fmt.Scan(&n, &k)

		if k >= n {
			fmt.Println((k + n - 1) / n)
		} else {
			if k%n == 0 {
				fmt.Println(1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	result := make([]string, t)
	for i := 0; i < t; i++ {
		var n int64
		var k int64
		scanf("%d %d\n", &n, &k)
		result[i] = strconv.FormatInt(solve(n, k), 10)
	}
	printf("%v", strings.Join(result, "\n"))
}

func solve(n int64, k int64) int64 {
	if k < n {
		if n / k == 0 {
			return 1
		}
		return 2
	}
	if k % n == 0 {
		return k / n
	}
	return k / n + 1
}

package main

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

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

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)

	result := make([]string, t)
	for i := 0; i < t; i++ {
		var n int64
		var k int64
		scanf("%d %d\n", &n, &k)
		result[i] = strconv.FormatInt(solve(n, k), 10)
	}
	printf("%v", strings.Join(result, "\n"))
}

func solve(n int64, k int64) int64 {
	if k < n {
		return solve(n, (n / k + 1) * k)
	}
	if k % n == 0 {
		return k / n
	}
	return k / n + 1
}

package main
import (
    "bufio"
    "os"
    "fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
func main() {
    var t int
    fmt.Fscan(in, &t)
    for t > 0 {
        t--
        var n, k int
        fmt.Fscan(in, &n, &k)
        if n > k {
            fmt.Fprintln(out, 2)
        } else {
            fmt.Fprintln(out, (k-1)/n+1)
        }
    }
    out.Flush()
}

package main
import (
    "bufio"
    "os"
    "fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
func main() {
    var t int
    fmt.Fscan(in, &t)
    for t > 0 {
        t--
        var n, k int
        fmt.Fscan(in, &n, &k)
        if n > k {
            fmt.Fprintln(out, (n-1)/k+1)
        } else {
            fmt.Fprintln(out, (k-1)/n+1)
        }
    }
    out.Flush()
}

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		if k == 1 {
			fmt.Println(1)
		} else if n > k {
			fmt.Println(2)
		} else if k%n == 0 {
			fmt.Println(k / n)
		} else {
			fmt.Println(k/n + 1)
		}
	}
}

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		if n > k {
			fmt.Println(2)
		} else if k%n == 0 {
			fmt.Println(k / n)
		} else {
			fmt.Println(k/n + 1)
		}
	}
}

package main

import "fmt"

func main() {
    //fmt.Println("hello world")
    var t int
    fmt.Scanln(&t)

    for i := 0; i < t; i++ {
        var n,k int
        fmt.Scan(&n)
        fmt.Scan(&k)
        med := ((n + k - 1) / k)
        ans := (k*med)
        fmt.Println((ans + n - 1) / n)
    }

    // fmt.Scanln(&n)
    // fmt.Scanln(&k)
    // fmt.Println(k)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var test int
	fmt.Scanln(&test)

	for t := 0; t < test; t++ {
		var n, k float64
		fmt.Scanln(&n, &k)

		if n > k {
			k = k * math.Ceil(n/k)
		}

		fmt.Println(math.Ceil(k / n))
	}
}

package main

import (
	"fmt"
)

func main() {

	var tcs int
	_, _ = fmt.Scan(&tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, k int64
		_, _ = fmt.Scan(&n, &k)

		if k < n {
			k *= 2
		}

		ans := (n + k - 1) / n

		fmt.Println(ans)
	}
}

package main
import "fmt"
import "math"
func main(){
	var t int;
	fmt.Scanln(&t)
	for ;t >0;t-- {
	var n,k float64
	fmt.Scanln(&n,&k);

	fmt.Println(math.Ceil(math.Max(k,n)/math.Min(k,n)));
	}
	// your code goes here
}


package main

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

func main() {
	//var read, _ = os.Open("dat.txt")
	//var write, _ = os.Create("result.txt")
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	var q int
	fmt.Fscan(read, &q)
	for iq := 0; iq < q; iq++ {
		var n int
		fmt.Fscan(read, &n)
		var t = make([]int, n)
		var exi = make([]bool, n+1)
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(read, &a)
			a = a - 1
			t[a] = t[a] + 1
		}
		sort.Ints(t)
		var res = t[0]
		var m = t[0]
		exi[m] = true
		var p = 1
		for i := 1; i < n; i++ {
			if m == t[i] {
				var p0 = p
				for p = p0; p < m; p++ {
					if !exi[m-p] {
						res = res + m - p
						exi[m-p] = true
						break
					}
				}
			} else {
				m = t[i]
				res = res + t[i]
				p = 1
				exi[m] = true
			}
		}
		fmt.Fprintln(write, res)
	}
	write.Flush()
	//read.Close()
	//write.Close()
}

package main

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

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

	var t, n, tp int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		types := make([]int, n+1)
		for i := 0; i < n; i++ {
			Fscan(in, &tp)
			types[tp]++
		}
		cnts := make([]int, n+1)
		for _, t := range types {
			cnts[t]++
		}
		ans := 0
		cnt := 0
		for i := n; i > 0; i-- {
			cnt += cnts[i]
			if cnt > 0 {
				ans += i
				cnt--
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

func main() {
	//var read, _ = os.Open("dat.txt")
	//var write, _ = os.Create("result.txt")
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	var q int
	fmt.Fscan(read, &q)
	for iq := 0; iq < q; iq++ {
		var n int
		fmt.Fscan(read, &n)
		var t = make([]int, n)
		var exi = make([]bool, n)
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(read, &a)
			a = a - 1
			t[a] = t[a] + 1
		}
		sort.Ints(t)
		var res = t[0]
		var m = t[0]
		exi[m] = true
		var p = 1
		for i := 1; i < n; i++ {
			if m == t[i] {
				if (m - p) > 0 {
					if !exi[m-p] {
						res = res + m - p
						exi[m-p] = true
						p = p + 1
					}
				}

			} else {
				m = t[i]
				res = res + t[i]
				p = 1
				exi[t[i]] = true
			}
		}
		fmt.Fprintln(write, res)
	}
	write.Flush()
	//read.Close()
	//write.Close()
}

package main

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

func main() {
	//var read, _ = os.Open("dat.txt")
	//var write, _ = os.Create("result.txt")
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	var q int
	fmt.Fscan(read, &q)
	for iq := 0; iq < q; iq++ {
		var n int
		fmt.Fscan(read, &n)
		var t = make([]int, n)
		var exi = make([]bool, n+1)
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(read, &a)
			a = a - 1
			t[a] = t[a] + 1
		}
		sort.Ints(t)
		var res = t[0]
		var m = t[0]
		exi[m] = true
		var p = 1
		for i := 1; i < n; i++ {
			if m == t[i] {
				if (m - p) > 0 {
					if !exi[m-p] {
						res = res + m - p
						exi[m-p] = true
					}
					p = p + 1
				}

			} else {
				m = t[i]
				res = res + t[i]
				p = 1
				exi[m] = true
			}
		}
		fmt.Fprintln(write, res)
	}
	write.Flush()
	//read.Close()
	//write.Close()
}