package main

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

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

func ans() {
	var n int
	Fscan(in, &n)
	var a []int = make([]int, n)
	var cnt int = 1
	for i := 1; i < n; i += 2 {
		a[i] = cnt
		cnt++
	}
	for i := 0; i < n; i += 2 {
		a[i] = cnt
		cnt++
	}
	for i := 0; i < n; i++ {
		Fprint(out, a[i], " ")
	}
	Fprintln(out)
}

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

package main

import "fmt"

func main() {
	var epochs, num int
	fmt.Scanf("%d\n", &epochs)
	for ; epochs > 0; epochs-- {
		fmt.Scanf("%d\n", &num)
		delta := num >> 1
		for i := 1; i <= delta; i++ {
			fmt.Printf("%d %d ", i+delta, i)
		}
		if num&1 == 1 {
			fmt.Println(num)
		} else {
			fmt.Println()
		}
	}
}

package main

import "fmt"

func main() {
	var epochs, num int
	fmt.Scanf("%d\n", &epochs)
	for ; epochs > 0; epochs-- {
		fmt.Scanf("%d\n", &num)
		delta := num & -2 >> 1
		for i := 1; i <= delta; i++ {
			fmt.Printf("%d %d ", i+delta, i)
		}
		if num&1 == 1 {
			fmt.Println(num)
		} else {
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

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

}
func Order(n int) {
	if n%2 == 0 {
		for i := 0; i < n-(n/2); i++ {
			fmt.Print(" ", n/2-i)
			fmt.Print(" ", n-i)
		}
	} else {
		for i := 0; i < n-(n/2); i++ {
			fmt.Print(" ", (n/2+1)-i) //3 2 1 //0 1 2 //n-(n/2) 3
			if i != n-(n/2)-1 {
				fmt.Print(" ", n-i) //5 4
			}
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1754B
Date: 10/30/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1754/B
Problem: CF1754B
**/
func (in *CF1754B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		r, s := 0, 1
		if n%2 != 0 {
			r = ((n - 1) / 2) + 1
		} else {
			r = (n / 2) + 1
		}

		for r <= n {
			if r == n && n%2 != 0 {
				fmt.Print(r, " ")
			} else {
				fmt.Print(r, s, " ")
			}
			r++
			s++
		}
		fmt.Println()
	}
}

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

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

package main

import (
	"fmt"
)

func work() {
	var n int
	fmt.Scanln(&n)
	k := n / 2
	if n%2 == 0 {
		for i := k; i > 0; i-- {
			fmt.Printf("%d %d ", i, i+k)
		}
	} else {
		for i := k + 1; i > 1; i-- {
			fmt.Printf("%d %d ", i, i+k)
		}
		fmt.Printf("1")
	}
	fmt.Println()
}

func main() {
	var T int
	fmt.Scanln(&T)
	for i := 0; i < T; i++ {
		work()
	}
}

package main

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

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

func solve(n int) string {
	var p []int
	for i := 1; i <= n/2; i++ {
		p = append(p, i+n/2)
		p = append(p, i)
	}
	if n%2 == 1 {
		p = append(p, n)
	}
	return strings.Trim(fmt.Sprint(p), "[]")
}

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

package main
import "fmt"

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

	m := []int{}
	answ := [][]int{}

	for s := 1; s <= t; s++ {
		fmt.Scan(&n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
		answ = append(answ, m)

	}

	for i := 0; i < t; i++ {
		for j := range answ[i] {
			fmt.Print(answ[i][j], " ")
		}
		fmt.Print("\n")
	}
}

package main

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

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

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

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

		for i := 0; i < n; i++ {
			if i%2 == 0 {
				if n/2 - i/2 > 0 {
					fmt.Fprintf(w, "%d ", n/2 - i/2)
				} else {
					fmt.Fprintf(w, "%d ", n)
				}
			} else {
				fmt.Fprintf(w, "%d ", 2*(n/2) - i/2)
			}
		}
		fmt.Fprintln(w, "")
	}

}

package main

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

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	if n%2 == 0 {
		val1, val2 := n/2, n
		for val1 > 0 {
			fmt.Fprint(out, val1, " ", val2, " ")
			val1--
			val2--
		}
		fmt.Fprintln(out)
	} else {
		val1, val2 := n/2+1, n
		for val1 > 1 {
			fmt.Fprint(out, val1, " ", val2, " ")
			val1--
			val2--
		}
		fmt.Fprintln(out, 1)
	}
}

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

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func GCD(a, b int) int {
	for a != b {
		if a > b {
			a -= b
		} else {
			b -= a
		}
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

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

	for t > 0{
		t--
		Fscan(r, &n)
		a := make([]int, n)
		left := make([]int, 0)
		right := make([]int, 0)
		for i := 1; i <= n/2; i++{
			left = append(left, i)
		}
		for i := n/2+1; i <= n/2*2; i++{
			right = append(right, i)
		}
		index1, index2 := len(left)-1, len(right)-1
		for i := 0; i < n/2*2; i++{
			if i % 2 == 0{
				a[i] = left[index1]
				index1--
			}else{
				a[i] = right[index2]
				index2--
			}
		}
		if n % 2 == 1{
			a[n-1] = n
		}
		for i := range a{
			if i != n - 1{
				Fprintf(w, "%d ", a[i])
			}else{
				Fprintf(w, "%d\n", a[i])
			}
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q, v [N]int
	path       []int
	maxminDiff int
	resPath    []int
)

func dfs(u int) {
	if u == n {
		res := n
		for i := 1; i < n; i++ {
			res = min(res, abs(path[i]-path[i-1]))
		}
		maxminDiff = max(maxminDiff, res)
		if res == maxminDiff {

			copy(resPath, path)
		}
		return
	}

	for i := 1; i <= n; i++ {
		if v[i] == 0 {
			v[i] = 1
			path = append(path, i)
			dfs(u + 1)
			path = path[:len(path)-1]
			v[i] = 0
		}
	}
}
func main() {
	var t int

	fmt.Fscan(reader, &t)

	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		resPath = make([]int, n)
		// 1 2 3 4 5 6
		// 2 4 6 1 3 5    2

		// 1 2 3 4 5 6 7 8
		// 1 4 7 2 5 8 3 6
		i, j := 1, n/2+1
		// 1 2 3 4
		// 2 4 1 3
		if n%2 == 1 {
			fmt.Printf("%d ", n)
		}
		for i <= n/2 && j <= n {
			fmt.Printf("%d ", j)
			fmt.Printf("%d ", i)
			i++
			j++
		}
		// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

		// 8

		fmt.Println()
	}
}

// [5 1 6 2 7 3 8 4]
// 4 5

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

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

// B. Kevin and Permutation
package main

import "fmt"

func main(){
	var t,n int
	fmt.Scan(&t)
	for i:=0;i<t;i++ {
		fmt.Scan(&n)
		x := (n/2) + (n & 1)

		for j:=0;j<(n/2);j++{
			fmt.Println(x-j,n-j," ")
		}
		if n & 1 != 0 {
			fmt.Println(1)
		}
	}
}

package main
import "fmt"

func main() {
    t := 0
	n := 0
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}
	answ := [][]int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
		answ = append(answ, m)

	}

	for i := 0; i < t; i++ {
		for j := range answ[i] {
			fmt.Print(answ[i][j], " ")
		}
		fmt.Print("\n")
	}
}

package main
import "fmt"

func main() {
    t := 1
	n := 10
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}
	answ := [][]int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
		answ = append(answ, m)

	}

	for i := 0; i < t; i++ {
		for j := range answ[i] {
			fmt.Print(answ[i][j], " ")
		}
		fmt.Print("\n")
	}
}

package main
import "fmt"

func main() {
    t := 0
	n := 0
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
		for _, i := range m {
			fmt.Print(i, " ")
		}
		fmt.Print("\n")
	}
}

package main
import "fmt"

func main() {
    t := 0
	n := 0
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
		for _, i := range m {
			fmt.Print(i, " ")
		}
	}
}

package main
import "fmt"

func main() {
    t := 1
	n := 11
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}

		for _, i := range m {
		    fmt.Print(i, " ")
	    }
	}
}

package main
import "fmt"

func main() {
    t := 1
	n := 11
	k := 0
    fmt.Scanf("%d", &t)

	m := []int{}

	for s := 1; s <= t; s++ {
		fmt.Scanf("%d", &n)
		m = []int{}
		if n % 2 == 0 {
			k = n / 2
			for i := k + 1; i <= n; i ++ {
				m = append(m, i)
				m = append(m, i - k)
			}
		} else {
			k = n / 2
			m = append(m, k + 1)
			for i := 1; i <= k; i ++ {
				m = append(m, i)
				m = append(m, i + k + 1)
			}
		}
	}

	for _, i := range m {
		fmt.Print(i, " ")
	}
}

package main

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

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

	for t > 0{
		t--
		Fscan(r, &n)
		if n == 4{
			a := []int{2,4,1,3}
			for i := range a{
				if i != n - 1{
					Fprintf(w, "%d ", a[i])
				}else{
					Fprintf(w, "%d\n", a[i])
				}
			}
			continue
		}
		a := make([]int, n)
		left := make([]int, 0)
		right := make([]int, 0)
		for i := 1; i <= (n+1)/2; i++{
			left = append(left, i)
		}
		for i := (n+1)/2+1; i <= n; i++{
			right = append(right, i)
		}
		index1, index2 := 0, 0
		for i := 0; i < n; i++{
			if i % 2 == 0{
				a[i] = left[index1]
				index1++
			}else{
				a[i] = right[index2]
				index2++
			}
		}
		for i := range a{
			if i != n - 1{
				Fprintf(w, "%d ", a[i])
			}else{
				Fprintf(w, "%d\n", a[i])
			}
		}
	}
}

package main

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

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

	for t > 0{
		t--
		Fscan(r, &n)
		if n == 4{
			a := []int{1,3,4,2}
			for i := range a{
				if i != n - 1{
					Fprintf(w, "%d ", a[i])
				}else{
					Fprintf(w, "%d\n", a[i])
				}
			}
			continue
		}
		a := make([]int, n)
		left := make([]int, 0)
		right := make([]int, 0)
		for i := 1; i <= (n+1)/2; i++{
			left = append(left, i)
		}
		for i := (n+1)/2+1; i <= n; i++{
			right = append(right, i)
		}
		index1, index2 := 0, 0
		for i := 0; i < n; i++{
			if i % 2 == 0{
				a[i] = left[index1]
				index1++
			}else{
				a[i] = right[index2]
				index2++
			}
		}
		for i := range a{
			if i != n - 1{
				Fprintf(w, "%d ", a[i])
			}else{
				Fprintf(w, "%d\n", a[i])
			}
		}
	}
}

package main

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

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

	for t > 0{
		t--
		Fscan(r, &n)
		a := make([]int, n)
		left := make([]int, 0)
		right := make([]int, 0)
		for i := 1; i <= (n+1)/2; i++{
			left = append(left, i)
		}
		for i := (n+1)/2+1; i <= n; i++{
			right = append(right, i)
		}
		index1, index2 := 0, 0
		for i := 0; i < n; i++{
			if i % 2 == 0{
				a[i] = left[index1]
				index1++
			}else{
				a[i] = right[index2]
				index2++
			}
		}
		for i := range a{
			Fprintf(w, "%d ", a[i])
		}
		Fprintln(w,)
	}
}

package main

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

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

	for t > 0{
		t--
		Fscan(r, &n)
		a := make([]int, n)
		left := make([]int, 0)
		right := make([]int, 0)
		for i := 1; i <= (n+1)/2; i++{
			left = append(left, i)
		}
		for i := (n+1)/2+1; i <= n; i++{
			right = append(right, i)
		}
		index1, index2 := 0, 0
		for i := 0; i < n; i++{
			if i % 2 == 0{
				a[i] = left[index1]
				index1++
			}else{
				a[i] = right[index2]
				index2++
			}
		}
		for i := range a{
			if i != n - 1{
				Fprintf(w, "%d ", a[i])
			}else{
				Fprintf(w, "%d\n", a[i])
			}
		}
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q [N]int
)

func main() {
	var t int

	fmt.Fscan(reader, &t)
	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		// 1 2 3 4 5 6
		// 2 4 6 1 3 5    2

		// 1 2 3 4 5 6 7 8
		// 1 4 7 2 5 8 3 6
		step := 1
		// 1 2 3 4
		// 2 4 1 3

		for {
			remain := n / step
			if remain <= step {
				break
			} else {
				step++
			}
		}
		for i := step; i >= 1; i-- {
			for j := i; j <= n; j += step {
				fmt.Printf("%d ", j)
			}
		}

		fmt.Println()
	}
}

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

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q [N]int
)

func main() {
	var t int

	fmt.Fscan(reader, &t)
	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		// 1 2 3 4 5 6
		// 2 4 6 1 3 5    2

		// 1 2 3 4 5 6 7 8
		// 1 4 7 2 5 8 3 6
		step := 1
		// 1 2 3 4
		// 2 4 1 3

		for {
			remain := n / step
			if remain <= step {
				break
			} else {
				step++
			}
		}
		fmt.Println(step)
		for i := step; i >= 1; i-- {
			for j := i; j <= n; j += step {
				fmt.Printf("%d ", j)
			}
		}

		fmt.Println()
	}
}

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

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q [N]int
)

func main() {
	var t int

	fmt.Fscan(reader, &t)
	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		// 1 2 3 4 5 6
		// 2 4 6 1 3 5    2

		// 1 2 3 4 5 6 7 8
		// 1 4 7 2 5 8 3 6
		step := 1
		// 4, 6,
		//
		for {
			remain := n / step
			if remain < step {
				break
			} else {
				step++
			}
		}
		for i := 1; i <= step; i++ {
			for j := i; j <= n; j += step {
				fmt.Printf("%d ", j)
			}
		}

		fmt.Println()
	}
}

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

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q [N]int
)

func main() {
	var t int

	fmt.Fscan(reader, &t)
	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		// 1 2 3 4
		// 2 4 1 3
		// 1 2 3 4 5 6
		// 2 4 6 1 3 5    2
		// 1 2 3 4 5 6    1

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

		for i := 2; i <= n; i += 2 {
			fmt.Printf("%d ", i)
		}

		for i := 1; i <= n; i += 2 {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
	}
}

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

// B. Kevin and Permutation
package main

import "fmt"

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

// B. Kevin and Permutation
package main

import "fmt"

func main(){
	var t,n,i int
	fmt.Scan(&t)
	for t != 0 {
		i = 1
		fmt.Scan(&n)
		for i<=n/2 {
			fmt.Print((i+n/2), " ", i, " ")
			i++
			if n%2 != 0 {
				fmt.Print(n)
			}
		}
		t--
	}
}

package main

import "fmt"

func main() {
	var epochs, num int
	fmt.Scanf("%d\n", &epochs)
	for ; epochs > 0; epochs-- {
		fmt.Scanf("%d\n", &num)
		stack := make([]int, 0, num)
		delta := (num + 1) / 2
		for i := 1; i < delta; i++ {
			stack = append(stack, i+delta, i)
		}
		if num&1 == 1 {
			stack = append(stack, delta)
		} else {
			stack = append(stack, delta+delta, delta)
		}
		for i := len(stack) - 1; i > 0; i-- {
			fmt.Printf("%d ", stack[i])
		}
		fmt.Printf("%d\n", stack[0])
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n)
		var arr = make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = i + 1
		}
		for i := 0; i < n; i++ {
			fmt.Print(arr[i])
		}
	}

}
func Swap() {

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1754B
Date: 10/30/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1754/B
Problem: CF1754B
**/
func (in *CF1754B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()

		if n == 4 {
			fmt.Println("2 4 1 3")
			continue
		}
		for i := 1; i <= n; i++ {
			if i%2 != 0 {
				fmt.Print(i, " ")
			}
		}
		for i := 1; i <= n; i++ {
			if i%2 == 0 {
				fmt.Print(i, " ")
			}
		}
		fmt.Println()
	}
}

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

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


package main

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

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

func max(a int, rest ...int) int {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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

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

	arr := make([]int, n)
	m1, m2 := math.MaxInt32, math.MaxInt32
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])

		if m1 > arr[i] {
			m1, m2 = arr[i], m1
		} else if m2 > arr[i] {
			m2 = arr[i]
		}
	}

	ans := (m1+1)/2 + (m2+1)/2
	for i := 0; i < n-2; i++ {
		ans = min(ans, (arr[i]+arr[i+2]+1)/2)
	}
	for i := 0; i < n-1; i++ {
		ans = min(ans, max((arr[i]+1)/2, (arr[i+1]+1)/2, (arr[i]+arr[i+1]+2)/3))
	}

	fmt.Fprintln(out, ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func I(a int) int64 { return int64(a) }
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int64 { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gi2() (int64,int64) { return gi(),gi() }
func gi3() (int64,int64,int64) { return gi(),gi(),gi() }
func gi4() (int64,int64,int64,int64) { return gi(),gi(),gi(),gi() }
func gis(n int64) []int64 { res := make([]int64,n); for i:=I(0);i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int64) []float64  { res := make([]float64,n); for i:=I(0);i<n;i++ { res[i] = gf() }; return res }
func gss(n int64) []string  { res := make([]string,n); for i:=I(0);i<n;i++ { res[i] = gs() }; return res }
func ia(m int64) []int64 { return make([]int64,m) }
func iai(m int64,v int64) []int64 { a := make([]int64,m); for i:=I(0);i<m;i++ { a[i] = v }; return a }
func twodi(n int64,m int64,v int64) [][]int64 {
	r := make([][]int64,n); for i:=I(0);i<n;i++ { x := make([]int64,m); for j:=I(0);j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int64) ([]int64,[]int64) { a,b := ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int64) ([]int64,[]int64,[]int64) { a,b,c := ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int64) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int64) int64 { if a < 0 { return -a }; return a }
func rev(a []int64) { i,j := I(0),I(len(a)-1); for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int64) int64 { if a > b { return a }; return b }
func min(a,b int64) int64 { if a > b { return b }; return a }
func tern(cond bool, a int64, b int64) int64 { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int64) int64 { ans := I(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int64) { for i:=I(0); i<I(len(a)); i++ { a[i] = 0 } }
func powmod(a,e,mod int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int64) (int64,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int64,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=I(1);i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
const inf int64 = 1000000000000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N := gi(); A := gis(N)
	best,s1,s2 := inf,inf,inf
	// Possibility 1, we shoot down two non-adjacent walls
	for _,a := range A { b := (a+1)/2; if b <= s1 { s1,s2 = b,s1 } else if b <= s2 { s2 = b } }
	best = s1+s2
	// Possibility 2, we shoot down two adjacent walls
	solveadjpair := func(a,b int64) int64 {
		if a < b { a,b = b,a }
		ans := (a+1)/2;
		if b > ans {
			ans = a-b; a -= 2*ans; b-= ans
			tt := a/3; ans += 2*tt; a -= 3*tt
			if a == 1 { ans++ } else if a == 2 { ans += 2 }
		}
		//fmt.Fprintf(wrtr,"DBG: solvepair:(%v,%v) = %v\n",a,b,ans)
		return ans
	}
	// Possibility 3, we shoot down two walls that have a one space gap
	solvenonadjpair := func(a,b int64) int64 {
		if a < b { a,b = b,a }
		return b + (a-b+1)/2
	}

	//fmt.Fprintf(wrtr,"DBG: best before solvepair:%v\n",best)
	for i:=I(0);i+1<N;i++ { cand := solveadjpair(A[i],A[i+1]); best = min(best,cand) }
	for i:=I(0);i+2<N;i++ { cand := solvenonadjpair(A[i],A[i+2]); best = min(best,cand) }
	fmt.Fprintln(wrtr,best)
}

package main

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

func max(a int, rest ...int) int {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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

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

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

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

	m1, m2 := math.MaxInt32, math.MaxInt32
	for _, v := range arr {
		if v < m1 {
			m1, m2 = v, m1
		} else if v < m2 {
			m2 = v
		}
	}

	resp := (m1+1)/2 + (m2+1)/2
	for i := 0; i < n-2; i++ {
		resp = min(resp, (arr[i]+arr[i+2]+1)/2)
	}

	for i := 0; i < n-1; i++ {
		resp = min(resp, max((arr[i]+1)/2, (arr[i+1]+1)/2, (arr[i]+arr[i+1]+2)/3))
	}

	fmt.Fprintln(out, resp)
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

func getAns(a int, b int) int {
	ans := 100_000_000

	l, r := 0, 10_000_000

	count := func(k1 int) int {
		ak2 := a - k1*2
		bk2 := (b-k1)/2 + (b-k1)%2
		k2 := max(max(ak2, bk2), 0)
		return k1 + k2
	}

	for r-l > 5 {
		x1 := l + (r-l)/3
		x2 := r - (r-l)/3

		if count(x1) < count(x2) {
			r = x2
		} else {
			l = x1
		}
	}

	for i := l; i <= r; i++ {
		ans = min(ans, count(i))
	}

	return ans
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	n := io.ReadInt()
	a := io.ReadIntSlice(n)

	ans := 100_000_000

	for i := 1; i < len(a)-1; i++ {
		mx := max(a[i-1], a[i+1])
		mn := min(a[i-1], a[i+1])
		dop := (mx-mn)/2 + (mx-mn)%2
		ans = min(ans, mn+dop)
	}

	for i := 0; i < len(a)-1; i++ {
		ans = min(ans, getAns(a[i], a[i+1]))
	}

	sort.Ints(a)
	ans = min(ans, a[0]/2+a[0]%2+a[1]/2+a[1]%2)

	fmt.Println(ans)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1674E(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	fi, se := int(1e9), int(1e9)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < fi {
			fi, se = a[i], fi
		} else if a[i] < se {
			se = a[i]
		}
	}
	ans := (fi+1)/2 + (se+1)/2
	for i := 1; i < n; i++ {
		v, w := a[i-1], a[i]
		if i < n-1 {
			m := min(v, a[i+1])
			ans = min(ans, m+(max(v, a[i+1])-m+1)/2)
		}
		if v < w {
			v, w = w, v
		}
		if v >= w*2 {
			ans = min(ans, (v+1)/2)
		} else {
			d := v - w
			w -= d
			ans = min(ans, d+w/3*2+w%3)
		}
	}
	Fprint(out, ans)
}

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

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

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min = [2]int{sections[0], math.MaxInt}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration1 > duration2 {
		if shot < duration1/2+duration1%2 {
			shot = duration1/2 + duration1%2
		}
	} else {
		if shot < duration2/2+duration2%2 {
			shot = duration2/2 + duration2%2
		}
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

package main

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

//func max(a, b int) int {if a > b {return a} else {return b}}
var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	left, right := make([]int, n), make([]int, n)
	left[0] = math.MaxInt
	right[n-1] = math.MaxInt
	two := make([]int, n)
	for i:=1;i<n;i++ {
		left[i] = min(left[i-1], nums[i-1])
	}
	for i:=n-2;i>=0;i-- {
		right[i] = min(right[i+1], nums[i+1])
	}
	ans := math.MaxInt
	for i:=0;i<n-1;i++ {
		var a, b int
		if nums[i] > nums[i+1] {
			a, b = nums[i], nums[i+1]
		} else{
			a, b = nums[i+1], nums[i]
		}
		if a > 2 * b {
			two[i] = (a+1)/2
		} else {
			two[i] = (a+b+2)/3
		}
		ans = min(ans, two[i])
	}
	for i := range nums {
		cur := (nums[i]+1)/2
		m := min(left[i], right[i])
		cur += (m+1)/2
		ans = min(ans, cur)
	}
	for i:=1;i<n-1;i++ {
		m := min(nums[i-1], nums[i+1])
		mm := max(nums[i-1], nums[i+1])
		ans = min(ans, m+(mm-m+1)/2)
	}
	fmt.Fprintln(w, ans)
}

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

package main

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

var N int64
var A []int64

var MX int64 = 10000000

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

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

func solve() int64 {
	res := MX
	for i := int64(0); i < N; i++ {
		n1 := (A[i] + 1) / 2
		cur1, cur2, cur3 := MX, MX, MX
		if i+1 < N {
			cur1 = n1
			if A[i+1] > n1 {
				cur1 += (A[i+1] - n1 + 1) / 2
			}
		}

		if i-1 >= 0 {
			cur2 = n1
			if A[i-1] > n1 {
				cur2 += (A[i-1] - n1 + 1) / 2
			}
		}

		if i+1 < N && i-1 >= 0 {
			a, b := min(A[i-1], A[i+1]), max(A[i-1], A[i+1])
			cur3 = a
			cur3 += (b - a + 1) / 2
			res = min(res, cur3)
		}

		res = min(res, cur1)
		res = min(res, cur2)
		res = min(res, cur3)

		//fmt.Println(cur1, cur2, cur3, res)
	}

	for i := int64(0); i < N-1; i++ {
		a, b := A[i], A[i+1]
		if a > b {
			a, b = b, a
		}

		cur := b - a
		a = 2*a - b
		if a > 0 {
			cur += a/3*2 + a%3
		}
		res = min(res, cur)
	}

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

	res = min(res, (A[0]+1)/2+(A[1]+1)/2)
	return res
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &N)
	A = make([]int64, N)
	for i := int64(0); i < N; i++ {
		fmt.Fscan(reader, &A[i])
	}

	fmt.Println(solve())
}

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min = [2]int{sections[0], math.MaxInt}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration1 > duration2+duration1%2 {
		if shot < duration1/2 {
			shot = duration1/2 + duration1%2
		}
	} else {
		if shot < duration2/2+duration2%2 {
			shot = duration2/2 + duration2%2
		}
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min = [2]int{sections[0], math.MaxInt}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration1 > duration2 {
		if shot < duration1/2 {
			shot = duration1/2 + duration1%2
		}
	} else {
		if shot < duration2/2 {
			shot = duration2/2 + duration2%2
		}
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min = [2]int{sections[0], math.MaxInt}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration1 > duration2 {
		if shot < duration1/2 {
			shot = duration1/2 + duration1%2
		}
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min = [2]int{sections[0], math.MaxInt}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Fscan(in, &sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Fscan(in, &sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min [2]int
	if sections[0] < sections[1] {
		min = [2]int{sections[0], sections[1]}
	} else {
		min = [2]int{sections[1], sections[0]}
	}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

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

func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var sectionNum int
	fmt.Scanln(&sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Scanln(&sections[i])
	}
	fmt.Fprintln(out, breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min [2]int
	if sections[0] < sections[1] {
		min = [2]int{sections[0], sections[1]}
	} else {
		min = [2]int{sections[1], sections[0]}
	}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

import (
	"fmt"
	"math"
)

func main() {
	var sectionNum int
	fmt.Scanln(&sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Scanln(&sections[i])
	}
	print(breakTheWall(sections))
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min [2]int
	if sections[0] < sections[1] {
		min = [2]int{sections[0], sections[1]}
	} else {
		min = [2]int{sections[1], sections[0]}
	}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

import (
	"fmt"
	"math"
)

func main() {
	var sectionNum int
	fmt.Scanln(&sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Scanln(&sections[i])
	}
	breakTheWall(sections)
}

func breakTheWall(sections []int) int {
	var max = math.MaxInt
	var min [2]int
	if sections[0] < sections[1] {
		min = [2]int{sections[0], sections[1]}
	} else {
		min = [2]int{sections[1], sections[0]}
	}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	return max
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

// hello.go
package main

import (
	"fmt"
	"math"
)

func main() {
	var sectionNum int
	fmt.Scanln(&sectionNum)
	sections := make([]int, sectionNum)
	for i := 0; i < sectionNum; i++ {
		fmt.Scanln(&sections[i])
	}
	breakTheWall(sections)
}

func breakTheWall(sections []int) {
	var max = math.MaxInt
	var min [2]int
	if sections[0] < sections[1] {
		min = [2]int{sections[0], sections[1]}
	} else {
		min = [2]int{sections[1], sections[0]}
	}
	for i := 0; i < len(sections)-1; i++ {
		if min[1] > sections[i+1] {
			if min[0] > sections[i+1] {
				min[1] = min[0]
				min[0] = sections[i+1]
			} else {
				min[1] = sections[i+1]
			}
		}
		if i+2 >= len(sections) {
			temp := getShot(sections[i], sections[i+1], 0)
			if max > temp {
				max = temp
			}
		} else {
			temp := getShot(sections[i], sections[i+1], sections[i+2])
			if max > temp {
				max = temp
			}
		}
	}
	if min[0]/2+min[0]%2+min[1]/2+min[1]%2 < max {
		max = min[0]/2 + min[0]%2 + min[1]/2 + min[1]%2
	}
	println(max)
}

func getShot(duration1, duration2, duration3 int) int {
	var shot int
	if (duration1+duration2)%3 != 0 {
		shot = (duration1+duration2)/3 + 1
	} else {
		shot = (duration1 + duration2) / 3
	}
	if duration3 != 0 && ((duration1+duration3)/2 < shot) {
		shot = (duration1+duration3)/2 + (duration1+duration3)%2
	}
	return shot
}

package main

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

var N int64
var A []int64

var MX int64 = 10000000

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

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

func solve() int64 {
	res := MX
	for i := int64(0); i < N; i++ {
		n1 := (A[i] + 1) / 2
		cur1, cur2, cur3 := MX, MX, MX
		if i+1 < N {
			cur1 = n1
			if A[i+1] > n1 {
				cur1 += (A[i+1] - n1 + 1) / 2
			}
		}

		if i-1 >= 0 {
			cur2 = n1
			if A[i-1] > n1 {
				cur2 += (A[i-1] - n1 + 1) / 2
			}
		}

		if i+1 < N && i-1 >= 0 {
			cur3 = max(A[i-1], A[i+1])
		}
		res = min(res, cur1)
		res = min(res, cur2)
		res = min(res, cur3)

		//fmt.Println(cur1, cur2, cur3, res)
	}

	for i := int64(0); i < N-1; i++ {
		a, b := A[i], A[i+1]
		if a > b {
			a, b = b, a
		}

		cur := b - a
		a = 2*a - b
		if a > 0 {
			cur += a/3*2 + a%3
		}
		res = min(res, cur)
	}

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

	res = min(res, (A[0]+1)/2+(A[1]+1)/2)
	return res
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &N)
	A = make([]int64, N)
	for i := int64(0); i < N; i++ {
		fmt.Fscan(reader, &A[i])
	}

	fmt.Println(solve())
}

package main

import (
	"fmt"
	"sort"
)

var N int64
var A []int64

var MX int64 = 10000000

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

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

func solve() int64 {
	res := MX
	for i := int64(0); i < N; i++ {
		n1 := (A[i] + 1) / 2
		cur1, cur2, cur3 := MX, MX, MX
		if i+1 < N {
			cur1 = n1
			if A[i+1] > n1 {
				cur1 += (A[i+1] - n1 + 1) / 2
			}
		}

		if i-1 >= 0 {
			cur2 = n1
			if A[i-1] > n1 {
				cur2 += (A[i-1] - n1 + 1) / 2
			}
		}

		if i+1 < N && i-1 >= 0 {
			cur3 = max(A[i-1], A[i+1])
		}
		res = min(res, cur1)
		res = min(res, cur2)
		res = min(res, cur3)

		//fmt.Println(cur1, cur2, cur3, res)
	}

	for i := int64(0); i < N-1; i++ {
		a, b := A[i], A[i+1]
		if a > b {
			a, b = b, a
		}

		cur := b - a
		a = 2*a - b
		cur += a/3*2 + a%3
		res = min(res, cur)
	}

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

	res = min(res, (A[0]+1)/2+(A[1]+1)/2)
	return res
}

func main() {
	fmt.Scanf("%d\n", &N)
	A = make([]int64, N)
	for i := int64(0); i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	fmt.Println(solve())
}

package main

import (
	"fmt"
	"sort"
)

var N int64
var A []int64

var MX int64 = 10000000

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

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

func solve() int64 {
	res := MX
	for i := int64(0); i < N; i++ {
		n1 := (A[i] + 1) / 2
		cur1, cur2, cur3 := MX, MX, MX
		if i+1 < N {
			cur1 = n1
			if A[i+1] > n1 {
				cur1 += (A[i+1] - n1 + 1) / 2
			}
		}

		if i-1 >= 0 {
			cur2 = n1
			if A[i-1] > n1 {
				cur2 += (A[i-1] - n1 + 1) / 2
			}
		}

		if i+1 < N && i-1 >= 0 {
			cur3 = max(A[i-1], A[i+1])
		}
		res = min(res, cur1)
		res = min(res, cur2)
		res = min(res, cur3)

		//fmt.Println(cur1, cur2, cur3, res)
	}

	for i := int64(0); i < N-1; i++ {
		a, b := A[i], A[i+1]
		step := int64(0)
		for a > 0 || b > 0 {
			if a < b {
				b -= 2
				a -= 1
			} else {
				a -= 2
				b -= 1
			}
			step++
		}
		res = min(res, step)
	}

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

	res = min(res, (A[0]+1)/2+(A[1]+1)/2)
	return res
}

func main() {
	fmt.Scanf("%d", &N)
	A = make([]int64, N)
	for i := int64(0); i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	fmt.Println(solve())
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func I(a int) int64 { return int64(a) }
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int64 { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gi2() (int64,int64) { return gi(),gi() }
func gi3() (int64,int64,int64) { return gi(),gi(),gi() }
func gi4() (int64,int64,int64,int64) { return gi(),gi(),gi(),gi() }
func gis(n int64) []int64 { res := make([]int64,n); for i:=I(0);i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int64) []float64  { res := make([]float64,n); for i:=I(0);i<n;i++ { res[i] = gf() }; return res }
func gss(n int64) []string  { res := make([]string,n); for i:=I(0);i<n;i++ { res[i] = gs() }; return res }
func ia(m int64) []int64 { return make([]int64,m) }
func iai(m int64,v int64) []int64 { a := make([]int64,m); for i:=I(0);i<m;i++ { a[i] = v }; return a }
func twodi(n int64,m int64,v int64) [][]int64 {
	r := make([][]int64,n); for i:=I(0);i<n;i++ { x := make([]int64,m); for j:=I(0);j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int64) ([]int64,[]int64) { a,b := ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int64) ([]int64,[]int64,[]int64) { a,b,c := ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int64) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int64) int64 { if a < 0 { return -a }; return a }
func rev(a []int64) { i,j := I(0),I(len(a)-1); for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int64) int64 { if a > b { return a }; return b }
func min(a,b int64) int64 { if a > b { return b }; return a }
func tern(cond bool, a int64, b int64) int64 { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int64) int64 { ans := I(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int64) { for i:=I(0); i<I(len(a)); i++ { a[i] = 0 } }
func powmod(a,e,mod int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int64) (int64,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int64,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=I(1);i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
const inf int64 = 1000000000000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N := gi(); A := gis(N)
	if N == 3 { fmt.Fprintf(wrtr,"DBG: N:%v A:%v\n",N,A) }
	best,s1,s2 := inf,inf,inf
	// Possibility 1, we shoot down two non-adjacent walls
	for _,a := range A { b := (a+1)/2; if b <= s1 { s1,s2 = b,s1 } else if b <= s2 { s2 = b } }
	best = s1+s2
	// Possibility 2, we shoot down two adjacent walls
	solvepair := func(a,b int64) int64 {
		if a < b { a,b = b,a }
		ans := (a+1)/2;
		if b > ans {
			ans = a-b; a -= 2*ans; b-= ans
			tt := a/3; ans += 2*tt; a -= 3*tt
			if a == 1 { ans++ } else if a == 2 { ans += 2 }
		}
		//fmt.Fprintf(wrtr,"DBG: solvepair:(%v,%v) = %v\n",a,b,ans)
		return ans
	}
	//fmt.Fprintf(wrtr,"DBG: best before solvepair:%v\n",best)
	for i:=I(0);i+1<N;i++ { cand := solvepair(A[i],A[i+1]); best = min(best,cand) }
	fmt.Fprintln(wrtr,best)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func I(a int) int64 { return int64(a) }
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int64 { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gi2() (int64,int64) { return gi(),gi() }
func gi3() (int64,int64,int64) { return gi(),gi(),gi() }
func gi4() (int64,int64,int64,int64) { return gi(),gi(),gi(),gi() }
func gis(n int64) []int64 { res := make([]int64,n); for i:=I(0);i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int64) []float64  { res := make([]float64,n); for i:=I(0);i<n;i++ { res[i] = gf() }; return res }
func gss(n int64) []string  { res := make([]string,n); for i:=I(0);i<n;i++ { res[i] = gs() }; return res }
func ia(m int64) []int64 { return make([]int64,m) }
func iai(m int64,v int64) []int64 { a := make([]int64,m); for i:=I(0);i<m;i++ { a[i] = v }; return a }
func twodi(n int64,m int64,v int64) [][]int64 {
	r := make([][]int64,n); for i:=I(0);i<n;i++ { x := make([]int64,m); for j:=I(0);j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int64) ([]int64,[]int64) { a,b := ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int64) ([]int64,[]int64,[]int64) { a,b,c := ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int64) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int64) int64 { if a < 0 { return -a }; return a }
func rev(a []int64) { i,j := I(0),I(len(a)-1); for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int64) int64 { if a > b { return a }; return b }
func min(a,b int64) int64 { if a > b { return b }; return a }
func tern(cond bool, a int64, b int64) int64 { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int64) int64 { ans := I(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int64) { for i:=I(0); i<I(len(a)); i++ { a[i] = 0 } }
func powmod(a,e,mod int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int64) (int64,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int64,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=I(1);i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
const inf int64 = 1000000000000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	//N := gi(); A := gis(N)
	N := I(3); A := []int64{1,8,1}
	best,s1,s2 := inf,inf,inf
	// Possibility 1, we shoot down two non-adjacent walls
	for _,a := range A { b := (a+1)/2; if b <= s1 { s1,s2 = b,s1 } else if b <= s2 { s2 = b } }
	best = s1+s2
	// Possibility 2, we shoot down two adjacent walls
	solvepair := func(a,b int64) int64 {
		if a < b { a,b = b,a }
		ans := (a+1)/2;
		if b > ans {
			ans = a-b; a -= 2*ans; b-= ans
			tt := a/3; ans += 2*tt; a -= 3*tt
			if a == 1 { ans++ } else if a == 2 { ans += 2 }
		}
		fmt.Fprintf(wrtr,"DBG: solvepair:(%v,%v) = %v\n",a,b,ans)
		return ans
	}
	fmt.Fprintf(wrtr,"DBG: best before solvepair:%v\n",best)
	for i:=I(0);i+1<N;i++ { cand := solvepair(A[i],A[i+1]); best = min(best,cand) }
	fmt.Fprintln(wrtr,best)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func I(a int) int64 { return int64(a) }
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int64 { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gi2() (int64,int64) { return gi(),gi() }
func gi3() (int64,int64,int64) { return gi(),gi(),gi() }
func gi4() (int64,int64,int64,int64) { return gi(),gi(),gi(),gi() }
func gis(n int64) []int64 { res := make([]int64,n); for i:=I(0);i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int64) []float64  { res := make([]float64,n); for i:=I(0);i<n;i++ { res[i] = gf() }; return res }
func gss(n int64) []string  { res := make([]string,n); for i:=I(0);i<n;i++ { res[i] = gs() }; return res }
func ia(m int64) []int64 { return make([]int64,m) }
func iai(m int64,v int64) []int64 { a := make([]int64,m); for i:=I(0);i<m;i++ { a[i] = v }; return a }
func twodi(n int64,m int64,v int64) [][]int64 {
	r := make([][]int64,n); for i:=I(0);i<n;i++ { x := make([]int64,m); for j:=I(0);j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int64) ([]int64,[]int64) { a,b := ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int64) ([]int64,[]int64,[]int64) { a,b,c := ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int64) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=I(0);i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int64) int64 { if a < 0 { return -a }; return a }
func rev(a []int64) { i,j := I(0),I(len(a)-1); for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int64) int64 { if a > b { return a }; return b }
func min(a,b int64) int64 { if a > b { return b }; return a }
func tern(cond bool, a int64, b int64) int64 { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int64) int64 { ans := I(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int64) { for i:=I(0); i<I(len(a)); i++ { a[i] = 0 } }
func powmod(a,e,mod int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int64) int64 { res, m := I(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int64) (int64,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int64,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=I(1);i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
const inf int64 = 1000000000000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N := gi(); A := gis(N)
	best,s1,s2 := inf,inf,inf
	// Possibility 1, we shoot down two non-adjacent walls
	for _,a := range A { b := (a+1)/2; if b <= s1 { s1,s2 = b,s1 } else if b <= s2 { s2 = b } }
	best = s1+s2
	// Possibility 2, we shoot down two adjacent walls
	solvepair := func(a,b int64) int64 {
		if a < b { a,b = b,a }
		s1 := (a+1)/2; if b <= s1 { return s1 }
		s2 := a-b; a -= 2*s2; b-= s2
		tt := a/3; s2 += 2*tt; a -= 3*tt
		if a == 1 { s2++ } else if a == 2 { s2 += 2 }
		return s2
	}
	for i:=I(0);i+1<N;i++ { cand := solvepair(A[i],A[i+1]); best = min(best,cand) }
	fmt.Println(best)
}

package main

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

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

func max(a int, rest ...int) int {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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

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

	arr := make([]int, n)
	m1, m2 := math.MaxInt32, math.MaxInt32
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])

		if m1 > arr[i] {
			m1, m2 = arr[i], m1
		} else if m2 > arr[i] {
			m2 = arr[i]
		}
	}

	ans := (m1+1)/2 + (m2+1)/2
	for i := 0; i < n-2; i++ {
		ans = min(ans, (arr[i]+arr[i+2]+1)/2)
	}
	for i := 1; i < n-1; i++ {
		ans = min(ans, max((arr[i]+1)/2, (arr[i+1]+1)/2, (arr[i]+arr[i+1]+2)/3))
	}

	fmt.Fprintln(out, ans)
}

package main

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

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

func max(a int, rest ...int) int {
	for _, v := range rest {
		if v > a {
			a = v
		}
	}
	return a
}

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

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

	arr := make([]int, n)
	m1, m2 := math.MaxInt32, math.MaxInt32
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])

		if m1 > arr[i] {
			m1, m2 = arr[i], m1
		} else if m2 > arr[i] {
			m2 = arr[i]
		}
	}

	ans := (m1+1)/2 + (m2+1)/2
	for i := 0; i < n-2; i++ {
		ans = min(ans, (arr[i]+arr[i+2])/2)
	}
	for i := 1; i < n-1; i++ {
		ans = min(ans, max((arr[i]+1)/2, (arr[i+1]+1)/2, (arr[i]+arr[i+1]+2)/3))
	}

	fmt.Fprintln(out, ans)
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

func getAns(a int, b int) int {
	ans := 100_000_000

	l, r := 0, 100_000

	count := func(k1 int) int {
		ak2 := a - k1*2
		bk2 := (b-k1)/2 + (b-k1)%2
		k2 := max(max(ak2, bk2), 0)
		return k1 + k2
	}

	for r-l > 5 {
		x1 := l + (r-l)/3
		x2 := r - (r-l)/3

		if count(x1) < count(x2) {
			r = x2
		} else {
			l = x1
		}
	}

	for i := l; i <= r; i++ {
		ans = min(ans, count(i))
	}

	return ans
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	n := io.ReadInt()
	a := io.ReadIntSlice(n)

	ans := 100_000_000

	for i := 1; i < len(a)-1; i++ {
		mx := max(a[i-1], a[i+1])
		mn := min(a[i-1], a[i+1])
		dop := (mx-mn)/2 + (mx-mn)%2
		ans = min(ans, mn+dop)
	}

	for i := 0; i < len(a)-1; i++ {
		ans = min(ans, getAns(a[i], a[i+1]))
	}

	sort.Ints(a)
	ans = min(ans, a[0]/2+a[0]%2+a[1]/2+a[1]%2)

	fmt.Println(ans)
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

func getAns(a int, b int) int {
	ans := 100_000_000

	l, r := 0, 100_000

	count := func(k1 int) int {
		ak2 := a - k1*2
		bk2 := (b-k1)/2 + (b-k1)%2
		k2 := max(max(ak2, bk2), 0)
		return k1 + k2
	}

	for r-l > 5 {
		x1 := l + (r-l)/3
		x2 := r - (r-l)/3

		if count(x1) < count(x2) {
			r = x2
		} else {
			l = x1
		}
	}

	for i := l; i <= r; i++ {
		ans = min(ans, count(i))
	}

	return ans
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	n := io.ReadInt()
	a := io.ReadIntSlice(n)

	ans := 100_000_000

	for i := 1; i < len(a)-1; i++ {
		ans = min(ans, max(a[i-1], a[i+1]))
	}

	for i := 0; i < len(a)-1; i++ {
		ans = min(ans, getAns(a[i], a[i+1]))
	}

	sort.Ints(a)
	ans = min(ans, a[0]/2+a[0]%2+a[1]/2+a[1]%2)

	fmt.Println(ans)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1674E(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	fi, se := int(1e9), int(1e9)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < fi {
			fi, se = a[i], fi
		} else if a[i] < se {
			se = a[i]
		}
	}
	ans := (fi+1)/2 + (se+1)/2
	for i := 1; i < n; i++ {
		v, w := a[i-1], a[i]
		if i < n-1 {
			ans = min(ans, max(v, a[i+1]))
		}
		if v < w {
			v, w = w, v
		}
		if v >= w*2 {
			ans = min(ans, (v+1)/2)
		} else {
			d := v - w
			w -= d
			ans = min(ans, d+w/3*2+w%3)
		}
	}
	Fprint(out, ans)
}

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

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