You are given an array $$$a$$$ of $$$n$$$ integers and a set $$$B$$$ of $$$m$$$ positive integers such that $$$1 \leq b_i \leq \lfloor \frac{n}{2} \rfloor$$$ for $$$1\le i\le m$$$, where $$$b_i$$$ is the $$$i$$$-th element of $$$B$$$. You can make the following operation on $$$a$$$:  Select some $$$x$$$ such that $$$x$$$ appears in $$$B$$$. Select an interval from array $$$a$$$ of size $$$x$$$ and multiply by $$$-1$$$ every element in the interval. Formally, select $$$l$$$ and $$$r$$$ such that $$$1\leq l\leq r \leq n$$$ and $$$r-l+1=x$$$, then assign $$$a_i:=-a_i$$$ for every $$$i$$$ such that $$$l\leq i\leq r$$$. Consider the following example, let $$$a=[0,6,-2,1,-4,5]$$$ and $$$B=\{1,2\}$$$:  $$$[0,6,-2,-1,4,5]$$$ is obtained after choosing size $$$2$$$ and $$$l=4$$$, $$$r=5$$$. $$$[0,6,2,-1,4,5]$$$ is obtained after choosing size $$$1$$$ and $$$l=3$$$, $$$r=3$$$. Find the maximum $$$\sum\limits_{i=1}^n {a_i}$$$ you can get after applying such operation any number of times (possibly zero).

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2\leq n \leq 10^6$$$, $$$1 \leq m \leq \lfloor \frac{n}{2} \rfloor$$$) — the number of elements of $$$a$$$ and $$$B$$$ respectively.  The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$-10^9\leq a_i \leq 10^9$$$).  The third line of each test case contains $$$m$$$ distinct positive integers $$$b_1,b_2,\ldots,b_m$$$ ($$$1 \leq b_i \leq \lfloor \frac{n}{2} \rfloor$$$) — the elements in the set $$$B$$$. It's guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.

For each test case print a single integer — the maximum possible sum of all $$$a_i$$$ after applying such operation any number of times.

NoteIn the first test, you can apply the operation $$$x=1$$$, $$$l=3$$$, $$$r=3$$$, and the operation $$$x=1$$$, $$$l=5$$$, $$$r=5$$$, then the array becomes $$$[0, 6, 2, 1, 4, 5]$$$.In the second test, you can apply the operation $$$x=2$$$, $$$l=2$$$, $$$r=3$$$, and the array becomes $$$[1, 1, -1, -1, 1, -1, 1]$$$, then apply the operation $$$x=2$$$, $$$l=3$$$, $$$r=4$$$, and the array becomes $$$[1, 1, 1, 1, 1, -1, 1]$$$. There is no way to achieve a sum bigger than $$$5$$$.

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func explore() {
	n := 6
	ks := []int{3}

	queue := []int{0}
	total := 1 << n
	seen := make([]bool, total)
	seen[0] = true
	for len(queue) > 0 {
		m := queue[0]
		queue = queue[1:]
		for _, k := range ks {
			k1 := (1<<k - 1)
			for i := 0; i+k <= n; i++ {
				mm := m ^ (k1 << i)
				if !seen[mm] {
					seen[mm] = true
					queue = append(queue, mm)
				}
			}
		}
	}
	cnt := 0
	for i := 0; i < total; i++ {
		if seen[i] {
			cnt++
			parity := 0
			for j := 0; j < n; j++ {
				if (i>>j)&1 == 1 {
					parity ^= (1 << (j % ks[0]))
				}
			}
			printf("%0"+strconv.Itoa(n)+"b %0"+strconv.Itoa(ks[0])+"b\n", i, parity)
		}
	}
	printf("found %d out of %d: %f\n", cnt, total, float64(cnt)/float64(total))
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

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

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

const TAM = int(1e6 + 10)

var a [TAM]int
var n, x int

func solve() int64 {
	var ans int64 = 0
	for i := 0; i < x; i++ {
		flag := 0
		var minAbs int = abs(a[i])
		for j := i; j < n; j += x {
			if abs(a[j]) < minAbs {
				minAbs = abs(a[j])
			}
			if a[j] < 0 {
				flag ^= 1
			}
		}
		if flag == 1 {
			ans += int64(minAbs)
		}
	}
	return ans
}

func solveCase() int64 {
	var m int
	var ans int64 = 0
	var sum int64 = 0
	scan(&n, &m)
	for i := 0; i < n; i++ {
		scan(&a[i])
		sum += int64(abs(a[i]))
	}
	x = 0
	var y int
	for i := 0; i < m; i++ {
		scan(&y)
		x = gcd(x, y)
	}
	ans = solve()
	for i := 0; i < x; i++ {
		a[i] = -a[i]
	}
	return sum - 2*min(ans, solve())
}

func main() {
	defer flush()
	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		printf("%d\n", solveCase())
	}
}

/**
If only 1 in B: Reaches anything. 1
If only 2 in B: Reaches even number of 1s. 1/2
...
If only x in B: Reaches any combination of bits in the prefix of size n-x+1.
								But the last x-1 are fixed. So it reaches 1/2^(x-1)

----

Given 0 <= i < x. Consider the answer for a[i], a[i+x], a[i+2x], ....
Applying flips on a[i, ..., i+x-1] and on a[i+1, ..., i+x] only flips
	a[i] and a[i+x], keeping everything else equal.
This shows the problem is reduced to the problem of B={2}.

This reaches 1/2^x. In order to account for all 1/2^(x-1). We must solve the
problem twice, with the initial array a and after flipping a[0, ..., x-1].

----

Theory: In the general case we can assume x=GCD(B).

This is true, because if B={a,b}. We have that a*x+b*y = gcd(a,b) = d, and
since a,b <= n/2, we should be able to build a sequence of flips to flip gcd(a,b)
consecutive elements. This is true because we can reorder a*x+b*y=d into something
like:
a - b + a - b + a + a - b + a - b = gcd(a,b)
In such a way that any prefix of the left hand side is always in [0, n].

Then by induction we can generalize.
*/

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, m, g int
		Fscan(in, &n, &m)
		tot := int64(0)

		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			tot += int64(abs(a[i]))
		}

		Fscan(in, &g)
		for i := 1; i < m; i++ {
			var v int
			Fscan(in, &v)
			g = gcd(g, v)
		}
		if g == 1 {
			Fprintln(out, tot)
			return
		}

		d := make([]int, n+5)
		flip := 0
		for i := range a {
			flip ^= d[i]
			if flip > 0 {
				a[i] = -a[i]
			}
			if i+g <= n && a[i] < 0 {
				flip ^= 1 // flip [i,i+g)
				d[i+g] ^= 1
				a[i] = -a[i]
			}
		}

		//Println(a)

		gs := make([]int, g)
		for _i := range gs {
			gs[_i] = 2e9
		}
		mi := make([]int, g)
		for _i := range mi {
			mi[_i] = 2e9
		}

		for i := len(a) - 1; i >= 0; i-- {
			v := a[i]
			j := i % g
			if gs[j] == 2e9 {
				gs[j] = v
			}
			mi[j] = min(mi[j], abs(v))
		}

		var s1, s2 int64
		for i, v := range gs {
			if v < 0 {
				s1 += int64(mi[i])
			} else {
				s2 += int64(mi[i])
			}
		}

		min2 := min64(s1,s2)

		Fprintln(out, tot-min2*2)
	}

	T := 1
	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) }

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

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

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

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


Vanya walks late at night along a straight street of length l, lit by n lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point l. Then the i-th lantern is at the point ai. The lantern lights all points of the street that are at the distance of at most d from it, where d is some positive number, common for all lanterns. Vanya wonders: what is the minimum light radius d should the lanterns have to light the whole street?

The first line contains two integers n, l (1 ≤ n ≤ 1000, 1 ≤ l ≤ 109) — the number of lanterns and the length of the street respectively.  The next line contains n integers ai (0 ≤ ai ≤ l). Multiple lanterns can be located at the same point. The lanterns may be located at the ends of the street.

Print the minimum light radius d, needed to light the whole street. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 9.

NoteConsider the second sample. At d = 2 the first lantern will light the segment [0, 4] of the street, and the second lantern will light segment [3, 5]. Thus, the whole street will be lit.

package main

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

var in *bufio.Scanner = bufio.NewScanner(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, l := nextInt(), nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	d := 2 * max(a[0], l - a[n - 1])
	for i := 1; i < n; i++ {
		d = max(d, a[i] - a[i - 1])
	}
	fmt.Printf("%.9f", float64(d) / 2)
}

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

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

package main

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

func main() {
	var n, l int
	var sum float64
	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&n, &l)

	ld := make([]int, n)

	for i := int(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &ld[i])
	}
	sort.Sort(sort.IntSlice(ld))

	last := 0
	for x, y := range ld {
		if x == 0 {
			sum = float64(y)
		}
		if x == n-1 {
			if sum < float64(l-y) {
				sum = float64(l - y)
			}
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		} else {
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		}
		last = y
	}

	fmt.Fprintln(ocr, sum)
	ocr.Flush()
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, l int
	var max float64
	fmt.Scan(&n, &l)
	var lights = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&lights[i])
	}
	sort.Ints(lights)
	if lights[0] != 0 {
		max = float64(lights[0] - 0)
	}
	for i := 1; i < n; i++ {
		if float64(lights[i] - lights[i - 1]) / 2 > max {
			max = float64(lights[i] - lights[i - 1]) / 2
		}
	}
	if lights[n - 1] != l && float64(l - lights[n - 1]) > max {
		max = float64(l - lights[n - 1])
	}
	fmt.Println(max)
}

package main

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

func main() {
	n, l := scanInt64(), scanInt64()
	arr := scanInt64Slice(n)
	var maxdist int64 = 0
	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
	for i := int64(0); i < n - 1; i++ {
		if arr[i + 1] - arr[i] > maxdist {
			maxdist = arr[i + 1] - arr[i]
		}
	}
	_, _ = printFmt(math.Max(float64(maxdist) / float64(2), float64(max(arr[0], l - arr[n - 1]))))
}

/*********************** 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 int64) []int64 {arr := make([]int64, n); for i := int64(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 ...int64) int64 { mn, _ := MnMx(args...); return mn }
func max(args ...int64) int64 { _, mx := MnMx(args...); return mx }
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 sorting(array []int64, fromElement int, toElement int) []int64 {
	var arr []int64
	for i := fromElement; i <= toElement; i++ {
		arr = append(arr, array[i])
	}
	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
	s := 0
	for i := fromElement; i <= toElement; i++ {
		array[i] = arr[s]
		s++
	}
	return array
}

func reverse(numbers []int64) []int64 {
	for i, j := 0, len(numbers)-1; i < j; i, j = i+1, j-1 {
		numbers[i], numbers[j] = numbers[j], numbers[i] }
	return numbers
}

func reversing(array []int64, fromElement int, toElement int) []int64 {
	var arr []int64
	for i := fromElement; i <= toElement; i++ {
		arr = append(arr, array[i])
	}
	arr = reverse(arr)
	s := 0
	for i := fromElement; i <= toElement; i++ {
		array[i] = arr[s]
		s++
	}
	return array
}

func arraySum(array []int) int {
	var ans = 0
	for _, element := range array {
		ans += element
	}
	return ans
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var d int

	var x int

	fmt.Scan(&n)
	fmt.Scan(&d)

	lanterns := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		lanterns[i] = x
	}
	sort.Ints(lanterns)

	var max float64
	for i, v := range lanterns {
		if i == 0 {
			r := float64(v)
			if v != 0 && r > max {
				max = r
			}
		} else {
			r := float64(v-lanterns[i-1]) / 2
			if r > max {
				max = r
			}
		}
		if i == len(lanterns)-1 && v != d {
			r := float64(d - v)
			if r > max {
				max = r
			}
		}
	}
	fmt.Printf("%2.10f\n", max)

}

package main

import (
	"fmt"
	"sort"
)

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

	a := make([]int, n)
	for i := 0; i<n;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	maxDiff := 0
	for i:=0;i<n-1;i++ {
		if maxDiff < a[i+1] - a[i] {
			maxDiff = a[i+1] - a[i]
		}
	}
	if maxDiff < 2*(l - a[n-1]) {
		maxDiff = 2*(l-a[n-1])
	}
	if maxDiff < 2*a[0] {
		maxDiff = 2*a[0]
	}

	fmt.Println(float64(maxDiff)/2.0)
}

package main

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

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 Println(a ...interface{}) {
	fmt.Println(a...)
}

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

func main() {
	var n,l int
	scan(&n,&l)
	arr:=make([]int,n)
	for i:=0;i<n;i++{
		scan(&arr[i])
	}
	sort.Ints(arr)
	var dist int = max(arr[0],l-arr[n-1])*2
	for i:=1;i<n;i++{
		dist=max(dist,arr[i]-arr[i-1])
	}
	Println(float64(dist)/2.0)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var l int
	var a []float64
	var min float64 = -1.0

	fmt.Scanf("%d %d\n", &n, &l)

	a = make([]float64, n+2)

	a[0] = 0
	a[n+2-1] = float64(l)

	for i := 1; i <= n; i++ {
		fmt.Scanf("%f", &a[i])
	}

	// fmt.Println(n, l)
	// fmt.Println(a)

	sort.Float64s(a)

	// fmt.Println(a)

	for i := 1; i <= n-1; i++ {
		if min < (a[i+1]-a[i])/2 {
			min = (a[i+1] - a[i]) / 2
		}
	}

	if (a[1] - a[0]) > min {
		min = a[1] - a[0]
	}
	if (a[n+1] - a[n]) > min {
		min = a[n+1] - a[n]
	}

	fmt.Printf("%.9f\n", min)
}

package main

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

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

func main() {
	var n, l int
	var arr []int
	fmt.Scanf("%d %d \n", &n, &l)

	reader := bufio.NewReader(os.Stdin)
	ss, _ := reader.ReadString('\n')
	list := strings.Split(strings.TrimRight(ss, "\r\n"), " ")

	for i := 0; i < n; i++ {
		t, _ := strconv.ParseUint(list[i], 10, 64)
		arr = append(arr, int(t))
	}
	sort.Ints(arr)

	res := 2 * max(arr[0], l-arr[n-1])
	last := arr[0]
	for i := 1; i < n; i++ {
		res = max(res, arr[i]-last)
		last = arr[i]
	}
	fmt.Print(float64(res) / float64(2))
}

package main

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

type ByValue []int64

func (v ByValue) Len() int {
	return len(v)
}

func (v ByValue) Swap(i, j int) {
	v[i], v[j] = v[j], v[i]
}

func (v ByValue) Less(i, j int) bool {
	return v[i] < v[j]
}

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

var (
	n      int
	l      int64
	a      []int64
	result float64
)

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

func out() {
	fmt.Fprintln(output, result)
	defer output.Flush()
}

func run() {
	sort.Sort(ByValue(a))

	var max int64 = 0
	var last int64 = a[0]
	for i := 1; i < n; i++ {
		var curr int64
		if i < n {
			curr = a[i]
		}
		if curr-last > max {
			max = curr - last
		}
		last = curr
	}

	result = float64(max) / 2

	if float64(a[0]) > result {
		result = float64(a[0])
	}

	if float64(l-a[n-1]) > result {
		result = float64(l - a[n-1])
	}
}

func main() {
	in()
	run()
	out()
}

package main

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

type pair struct {
    a, b int
}

func main() {
    start := time.Now()
    defer func () {
        run := time.Since(start)
        _ = run
        // fmt.Println("Run in", run)
    }()

    stdin := bufio.NewReader(os.Stdin)

    var n int
    var l float64
    fmt.Fscan(stdin, &n, &l)

    var a = make([]float64, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(stdin, &a[i])
    }
    sort.Slice(a[:], func (i, j int) bool {
        return a[i] < a[j]
    })
    // fmt.Println(a)

    check := func (d float64) bool {
        if a[0] != 0 && a[0] - d > 0 {
            return false
        }
        if a[n-1] != l && a[n-1] + d < l {
            return false
        }
        for i := 1; i < n; i++ {
            if a[i-1] + d < a[i] - d {
                return false
            }
        }
        return true
    }

    var lo, hi float64 = 0, float64(l)
    var mid float64
    for x := 10000; x > 0; x-- {
        mid = (hi + lo) / 2
        // fmt.Println(lo, mid, hi, check(mid))
        if check(mid) {
            hi = mid
        } else {
            lo = mid
        }
    }
    fmt.Printf("%.9f\n", mid)
    //fmt.Println(check(1.999999999))
}

package main

import "bufio"
import "os"
import "fmt"
import "sort"

func Read(s *bufio.Reader) string {
    line, _ := s.ReadString('\n')
    return line
}

func Write(s *bufio.Writer, a ...interface{}) {
    fmt.Fprintln(s, a...)
    s.Flush()
}

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

    var n, l int
    line, _ := reader.ReadString(' ')
    fmt.Sscanln(line, &n)
    fmt.Sscanln(Read(reader), &l)

    a := make([]int, n)

    for i := 0; i < n - 1; i++ {
        line, _ := reader.ReadString(' ')
        fmt.Sscanln(line, &a[i])
    }

    fmt.Sscanln(Read(reader), &a[n - 1])

    sort.Ints(a)

    var max float64 = float64(a[0] * 2)

    diff := (l - a[n - 1]) * 2
    if float64(diff) > max {
        max = float64(diff)
    }

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

    writer := bufio.NewWriter(os.Stdout)
    fmt.Fprintf(writer, "%.9f", max / 2.0)

    writer.Flush()
}

package main

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

var reader = bufio.NewReader(os.Stdin)

func main() {
	var n, l int

	fmt.Fscan(reader, &n, &l)

	a := make([]int, n)

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

	sort.Ints(a)

	var d float64

	for i := 0; i < n; i++ {
		if i == 0 {
			d = float64(a[i] - 0)
		}

		if i == n-1 {
			if float64(l-a[i]) > d {
				d = float64(l - a[i])
			}
		}

		if i == 0 {
			continue
		}

		if float64(a[i]-a[i-1])/2 > d {
			d = float64(a[i]-a[i-1]) / 2
		}
	}

	fmt.Println(d)
}

package main

import(
	"fmt"
	"sort"
	"math"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d\n", &n, &l)
	arr := []int{}
	var tmp int
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	fmt.Scanf("%d\n", &tmp)
	arr = append(arr, tmp)

	sort.Ints(arr)
	res := 2*math.Max(float64(arr[0]), float64(l-arr[len(arr)-1]))
	for i := 0; i < n-1; i++ {
		res = math.Max(res, float64(arr[i+1] - arr[i]))
	}

	fmt.Printf("%.10f\n",res/2)
}

package main

import (
	"fmt"
	"sort"
	"math"
)

func get_optimal_lantern_radius(lantern_pos []int, n, l int) float64 {
	sort.Ints(lantern_pos)
	// 2 5
	start_gap := lantern_pos[0] // start_gap = 2
	end_gap := l - lantern_pos[n - 1] // end_gap = 5 - 5 = 0
	boundary_gap := start_gap // boundary_gap = 2
	if end_gap > start_gap {
		boundary_gap = end_gap
	}
	max_gap := 0
	for i := 0; i < n - 1; i++ {
		// gap between 0 and 3 is 3
		gap := lantern_pos[i + 1] - lantern_pos[i]
		if gap > max_gap {
			max_gap = gap
		}
	}
	return math.Max(float64(boundary_gap), float64(max_gap) / 2.0)
}

func main() {
	var n, l int
	fmt.Scanln(&n, &l)
	lantern_pos := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &lantern_pos[i])
	}
	fmt.Println(get_optimal_lantern_radius(lantern_pos, n, l))
}

package main

import (
	"fmt"
	"sort"
)

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

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	z := float64(max(float64(a[0]), float64(l-a[n-1])))
	for i := 0; i < n-1; i++ {
		z = max(z, float64(a[i+1]-a[i])/2.0)
	}
	fmt.Printf("%.10f\n", z)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

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

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

	sort.Ints(lanterns)
	radious := float64(lanterns[0])
	r := float64(l - lanterns[n-1])
	radious = math.Max(radious, r)

	for i := 0; i < n-1; i++ {
		r = float64(lanterns[i+1]-lanterns[i]) / 2
		radious = math.Max(radious, r)
	}

	fmt.Printf("%.10f", radious)
}

/**
 * Vanya and lanterns
 * http://codeforces.com/problemset/problem/492/B
 * Tue Oct 20 23:35
 * author: smanurung
 */

package main

import (
	"fmt"
)

/**
 * Bubble sort O(n^2).
 */
func bubble(ar []int) {
	n := len(ar)

	for ;; {
		swap := false
		for i := 1; i < n; i++ {
			if ar[i - 1] > ar[i] {
				temp := ar[i - 1]
				ar[i - 1] = ar[i]
				ar[i] = temp

				swap = true
			}
		}
		if !swap {
			break
		}
	}
	return
}

func main() {
	var n, l, t int
	var ar []int

	fmt.Scanf("%d %d\n", &n, &l)
	for i := 0; i < n; i ++ {
		fmt.Scanf("%d", &t)
		ar = append(ar, t)
	}

	bubble(ar)
	// fmt.Println(ar)

	br1 := ar[0] - 0
	br2 := l - ar[n -1]

	max := map[bool]float64{true: float64(br1), false: float64(br2)}[br1 > br2]
	for i := 1; i < n; i++ {
		tmp := float64(ar[i] - ar[i - 1]) / float64(2)
		if tmp > max {
			max = tmp
		}
	}
	fmt.Printf("%.9f\n", max)
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n, l int
var a []float64

func main() {
	fmt.Fscan(reader, &n, &l)
	a = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}
	sort.Sort(sort.Float64Slice(a))
	ans := 0.0
	for i := 0; i < n-1; i++ {
		if ans < (a[i+1]-a[i])/2 {
			ans = (a[i+1] - a[i]) / 2
		}
	}
	if ans < a[0] {
		ans = a[0]
	}
	if ans < float64(l)-a[n-1] {
		ans = float64(l) - a[n-1]
	}

	fmt.Println(ans)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	var l, max uint64
	fmt.Scan(&n, &l)
	var light []uint64 = make([]uint64, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&light[i])
	}
	sort.Slice(light, func(i, j int) bool { return light[i] < light[j] })
	max = 0
	for i := 0; i < n-1; i++ {
		diff := light[i+1] - light[i]
		if max < diff {
			max = diff
		}
	}
	fmt.Printf("%.10f", math.Max(float64(max)/2.0, math.Max(float64(light[0]), float64(l-light[n-1]))))

}

// 0 1 2 3 4 5
//     1     1
// 7 15
// 15 5 3 7 9 14 0
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// |     |   |   |   |             |  |

package main

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

func main() {
	var n, l int
	fmt.Scanln(&n, &l)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	a := make([]int, n)
	for i, v := range strings.Split(scanner.Text(), " ") {
		x, _ := strconv.ParseInt(v, 10, 0)
		a[i] = int(x)
	}
	sort.Ints(a)
	max := float64(a[0])
	if float64(l - a[n - 1]) > max {
		max = float64(l - a[n - 1])
	}
	for i, _ := range a {
		if i == 0 {
			continue
		}
		current := math.Abs(float64(a[i - 1] - a[i])) / 2.0
		if current > max {
			max = current
		}
	}
	fmt.Printf("%.9f", max)
}

package main

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

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

	var n, m int
	fmt.Fscan(reader, &n, &m)

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

	sort.Ints(arr)
	var mx int
	for i := 0; i < n-1; i++ {
		mx = max(mx, arr[i+1]-arr[i])

	}

	mx = max(mx, max(arr[0]*2, (m-arr[n-1])*2))
	fmt.Printf("%.6f", float64(mx)/2)
}

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

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
    "math"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    l := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    sort.Ints(a)
    ans := math.Max(float64(a[0]), float64(l - a[n - 1]))
    for i := 1; i < n; i++ {
        d := float64(a[i] - a[i - 1]) / 2.0
        if ans < d {
            ans = d
        }
    }
    fmt.Fprintln(out, ans)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, l int
	fmt.Scan(&n)
	fmt.Scan(&l)
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var minRadius float64 = float64(a[0] - 0)
	for i := 0; i < n-1; i++ {
		currRadius := float64(a[i+1]-a[i]) / 2.
		if minRadius < currRadius {
			minRadius = currRadius
		}
	}
	if minRadius < float64(l-a[n-1]) {
		minRadius = float64(l - a[n-1])
	}
	fmt.Printf("%.9f\n", minRadius)
}

package main

import (
	"fmt"
	"math"
	"sort"
)

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

func main() {
	n, l := 0, 0
	fmt.Scanf("%d %d\n", &n, &l)
	as := make([]int, n)
	for i := range as {
		fmt.Scanf("%d", &as[i])
	}
	sort.Ints(as)
	dEnds := max(as[0]-0, l-as[n-1])
	maxd := 0
	for i := 1; i < len(as); i++ {
		d := as[i] - as[i-1]
		if d > maxd {
			maxd = d
		}
	}
	dInbetween := float64(maxd) / 2
	fmt.Println(math.Max(dInbetween, float64(dEnds)))
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
	used bool
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

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

func solution(reader io.Reader, writer io.Writer) {
	var n, l int
	fmt.Fscanf(reader, "%d %d\n", &n, &l)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	a = sort(a)
	r := float64(a[0])
	r = max(r, float64(l - a[n - 1]))
	for i := 0; i < n - 1; i++ {
		r = max(r, float64(a[i + 1] - a[i]) / 2)
	}
	fmt.Fprintf(writer, "%0.9f", r)
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

import (
	"fmt"
	"sort"
)

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

// https://codeforces.com/problemset/problem/492/B
// комментарии к решению
// Для решения нам необходимо найти максимальное расстояние между соседними фонарями,
// с учетом границ улицы, и поделить его на 2
// Т.к. фонари идут не по порядку, то сортируем входные данные
func taskSolution(a []int, l int) string {
	sort.Sort(sort.IntSlice(a))
	maxDiff := max(a[0], l-a[len(a)-1]) * 2
	for i := 1; i < len(a); i += 1 {
		maxDiff = max(maxDiff, a[i]-a[i-1])
	}
	ans := fmt.Sprintf("%.10f", float64(maxDiff)/float64(2))
	return ans
}

func main() {
	var n, l int
	if _, err := fmt.Scan(&n, &l); err != nil {
		panic(err)
	}

	a := []int{}
	for i := 0; i < n; i += 1 {
		var ai int
		if _, err := fmt.Scan(&ai); err != nil {
			panic(err)
		}
		a = append(a, ai)
	}

	fmt.Println(taskSolution(a, l))
}

package main

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

var in *bufio.Scanner = bufio.NewScanner(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, l := nextInt(), nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	d := 2 * max(a[0], l - a[n - 1])
	for i := 1; i < n; i++ {
		d = max(d, a[i] - a[i - 1])
	}
	fmt.Println(float32(d) / 2.0)
}

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

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

package main

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

var in *bufio.Scanner = bufio.NewScanner(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, l := nextInt(), nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	sort.Ints(a)

	d := 2 * max(a[0], l - a[n - 1])
	for i := 1; i < n; i++ {
		d = max(d, a[i] - a[i - 1])
	}
	fmt.Printf("%.9f", float32(d) / 2.0)
}

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

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

package main

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

func main() {
	var n, l int
	var sum float64
	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&n, &l)

	ld := make([]int, n)

	for i := int(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &ld[i])
	}
	sort.Sort(sort.IntSlice(ld))

	last := 0
	for x, y := range ld {
		if x == 0 {
			sum = float64(y)
		} else if x == n-1 {
			if sum < float64(l-y) {
				sum = float64(l - y)
			}
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		} else {
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		}
		last = y
	}

	fmt.Fprintln(ocr, sum)
	ocr.Flush()
}

package main

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

func main() {
	var n, l int
	var sum float64
	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&n, &l)

	ld := make([]int, n)

	for i := int(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &ld[i])
	}
	sort.Sort(sort.IntSlice(ld))

	last := 0
	for x, y := range ld {
		if x == 0 {
			sum = float64(y)
		} else if x == n-1 {
			if sum < float64(l-y) {
				sum = float64(y)
			}
		} else {
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		}
		last = y
	}

	fmt.Fprintln(ocr, sum)
	ocr.Flush()
}

package main

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

func main() {
	var n, l int
	var sum float64
	scr := bufio.NewReader(os.Stdin)
	ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&n, &l)

	ld := make([]int, n)

	for i := int(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &ld[i])
	}
	sort.Sort(sort.IntSlice(ld))

	last := 0
	for x, y := range ld {
		if x == 0 {
			sum = float64(y)
		} else if x == n-1 {
			if sum < float64(l-y) {
				sum = float64(y)
			}
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		} else {
			if sum < float64(y-last)/float64(2) {
				sum = float64(y-last) / float64(2)
			}
		}
		last = y
	}

	fmt.Fprintln(ocr, sum)
	ocr.Flush()
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, l int
	var max float32
	fmt.Scan(&n, &l)
	var lights = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&lights[i])
	}
	sort.Ints(lights)
	if lights[0] != 0 {
		max = float32(lights[0] - 0)
	}
	for i := 1; i < n; i++ {
		if float32(lights[i] - lights[i - 1]) / 2 > max {
			max = float32(lights[i] - lights[i - 1]) / 2
		}
	}
	if lights[n - 1] != l && float32(l - lights[n - 1]) > max {
		max = float32(l - lights[n - 1])
	}
	fmt.Println(max)
}

package main

import (
	"fmt"
	"sort"
)

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

	a := make([]int, n)
	for i := 0; i<n;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	a = append(a,l)

	maxDiff := 0
	for i:=0;i<n;i++ {
		if maxDiff < a[i+1] - a[i] {
			maxDiff = a[i+1] - a[i]
		}
	}
	fmt.Println(float32(maxDiff)/2.0)
}

package main

import (
	"fmt"
	"sort"
)

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

	a := make([]int, n)
	for i := 0; i<n;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	maxDiff := 0
	for i:=0;i<n-1;i++ {
		if maxDiff < a[i+1] - a[i] {
			maxDiff = a[i+1] - a[i]
		}
	}
	if maxDiff < 2*(l - a[n-1]) {
		maxDiff = 2*(l-a[n-1])
	}
	if maxDiff < 2*a[0] {
		maxDiff = 2*a[0]
	}

	fmt.Println(float32(maxDiff)/2.0)
}

package main

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

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 Println(a ...interface{}) {
	fmt.Println(a...)
}

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

func main() {
	var n,l int
	scan(&n,&l)
	arr:=make([]int,n)
	for i:=0;i<n;i++{
		scan(&arr[i])
	}
	sort.Ints(arr)
	var dist int = max(arr[0],l-arr[n-1])
	for i:=1;i<n;i++{
		dist=max(dist,arr[i]-arr[i-1])
	}
	Println(float64(dist)/2.0)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var l int
	var a []float64
	var min float64 = -1.0

	fmt.Scanf("%d %d\n", &n, &l)

	a = make([]float64, n+2)

	a[0] = 0
	a[n+2-1] = float64(l)

	for i := 1; i <= n; i++ {
		fmt.Scanf("%f", &a[i])
	}

	fmt.Println(n, l)
	fmt.Println(a)

	sort.Float64s(a)

	fmt.Println(a)

	for i := 1; i <= n-1; i++ {
		if min < (a[i+1]-a[i])/2 {
			min = (a[i+1] - a[i]) / 2
		}
	}

	if (a[1] - a[0]) > min {
		min = a[1] - a[0]
	}
	if (a[n+1] - a[n]) > min {
		min = a[n+1] - a[n]
	}

	fmt.Printf("%.9f\n", min)
}

package main

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

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

func main() {
	var n, l int
	var arr []int
	fmt.Scanf("%d %d \n", &n, &l)

	reader := bufio.NewReader(os.Stdin)
	ss, _ := reader.ReadString('\n')
	list := strings.Split(strings.TrimRight(ss, "\r\n"), " ")

	for i := 0; i < n; i++ {
		t, _ := strconv.ParseUint(list[i], 10, 64)
		arr = append(arr, int(t))
	}
	sort.Ints(arr)

	res := 2 * max(arr[0], l-arr[n-1])
	last := arr[0]
	for i := 1; i < n; i++ {
		res = max(res, arr[i]-last)
		last = arr[i]
	}
	fmt.Print(float64(5) / float64(2))
}

package main

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

var reader = bufio.NewReader(os.Stdin)

func main() {
	var n, l int

	fmt.Fscan(reader, &n, &l)

	a := make([]int, n)

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

	sort.Ints(a)

	var d float64

	for i := 0; i < n; i++ {
		if i == 0 {
			d = float64(a[i] - 0)
			continue
		}

		if i == n-1 {
			if float64(l-a[i]) > d {
				d = float64(l - a[i])
			}
		}

		if float64(a[i]-a[i-1])/2 > d {
			d = float64(a[i]-a[i-1]) / 2
		}
	}

	fmt.Println(d)
}

package main

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

var reader = bufio.NewReader(os.Stdin)

func main() {
	var n, l int

	fmt.Fscan(reader, &n, &l)

	a := make([]int, n)

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

	sort.Ints(a)

	var d float64

	for i := 0; i < n; i++ {
		if i == 0 {
			d = float64(a[i] - 0)
			continue
		} else if i == n-1 {
			if float64(l-a[i]) > d {
				d = float64(l - a[i])
			}
		}

		if float64(a[i]-a[i-1])/2 > d {
			d = float64(a[i]-a[i-1]) / 2
		}
	}

	fmt.Println(d)
}

package main

import(
	"fmt"
	"sort"
	"math"
)

func main() {
	var n, l int
	fmt.Scanf("%d %d\n", &n, &l)
	arr := []int{}
	var tmp int
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	fmt.Scanf("%d\n", &tmp)
	arr = append(arr, tmp)

	sort.Ints(arr)
	res := 2*math.Max(float64(arr[0]), float64(arr[len(arr)-1]-l))
	for i := 0; i < n-1; i++ {
		res = math.Max(res, float64(arr[i+1] - arr[i]))
	}

	fmt.Printf("%.10f\n",res/2)
}

//
// Theater Square
// http://codeforces.com/problemset/problem/1/A
// Mon Oct 19 22:43
// author: smanurung
//

package main

import (
	"fmt"
	"math"
)

type f float64
type i6 int64

func flagstone(n, m, a int) i6 {
	return i6(math.Ceil(float64(m)/float64(a))) * i6(math.Ceil(float64(n)/float64(a)))
}

func main() {
	var m, n, a int
	fmt.Scanf("%d %d %d\n", &n, &m, &a)

	fmt.Println(flagstone(n, m, a))
}

package main

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

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

	var n, m int
	fmt.Fscan(reader, &n, &m)

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

	sort.Ints(arr)
	var mx int
	for i := 0; i < n-1; i++ {
		mx = max(mx, arr[i+1]-arr[i])

	}

	mx = max(mx, max(arr[0]*2, m-arr[n-1]*2))
	fmt.Printf("%.6f", float64(mx)/2)
}

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


You are given four integers $$$n$$$, $$$c_0$$$, $$$c_1$$$ and $$$h$$$ and a binary string $$$s$$$ of length $$$n$$$.A binary string is a string consisting of characters $$$0$$$ and $$$1$$$.You can change any character of the string $$$s$$$ (the string should be still binary after the change). You should pay $$$h$$$ coins for each change.After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character $$$0$$$ you should pay $$$c_0$$$ coins, to buy the character $$$1$$$ you should pay $$$c_1$$$ coins.Find the minimum number of coins needed to buy the string.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10$$$) — the number of test cases. Next $$$2t$$$ lines contain descriptions of test cases. The first line of the description of each test case contains four integers $$$n$$$, $$$c_{0}$$$, $$$c_{1}$$$, $$$h$$$ ($$$1 \leq n, c_{0}, c_{1}, h \leq 1000$$$). The second line of the description of each test case contains the binary string $$$s$$$ of length $$$n$$$.

For each test case print a single integer — the minimum number of coins needed to buy the string.

NoteIn the first test case, you can buy all characters and pay $$$3$$$ coins, because both characters $$$0$$$ and $$$1$$$ costs $$$1$$$ coin.In the second test case, you can firstly change $$$2$$$-nd and $$$4$$$-th symbols of the string from $$$1$$$ to $$$0$$$ and pay $$$2$$$ coins for that. Your string will be $$$00000$$$. After that, you can buy the string and pay $$$5 \cdot 10 = 50$$$ coins for that. The total number of coins paid will be $$$2 + 50 = 52$$$.

package main

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

func main() {

	var t int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanf(reader, "%d\n", &t)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	for i := 0; i < t; i++ {
		var n, c0, c1, h int
		fmt.Fscanf(reader, "%d %d %d %d\n", &n, &c0, &c1, &h)
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		oneCnt := 0
		zeroCnt := 0
		for j := range s {
			if s[j] == '1' {
				oneCnt++
			} else {
				zeroCnt++
			}
		}
		if h + c1 < c0 {
			c0 = h + c1
		} else if h + c0 < c1 {
			c1 = h + c0
		}
		fmt.Fprintf(writer,"%d\n", oneCnt * c1 + zeroCnt * c0)
	}
}

package main

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

func main() {
	var t, n, c0, c1, h int
	var s string

	reader := bufio.NewReader(os.Stdin)

	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &c0, &c1, &h)
		fmt.Fscan(reader, &s)

		fmt.Println(cal(n, c0, c1, h, s))
	}
}

func cal(n int, c0 int, c1 int, h int, s string) int {

	buyD := 0
	buyC := 0

	for i := range s {
		if s[i] == '0' {
			buyD += c0
		}
		if s[i] == '1' {
			buyD += c1
		}
	}

	for i := range s {
		if s[i] == '0' {
			if c0 > c1 {
				buyC += h
				buyC += c1
			} else {
				buyC += c0
			}
		}

		if s[i] == '1' {
			if c1 > c0 {
				buyC += h
				buyC += c0
			} else {
				buyC += c1
			}
		}
	}

	if buyC >= buyD {
		return buyD
	} else {
		return buyC
	}

}

package main

import (
    "fmt"
)

func solve() {
    var n, c0, c1, h int;
    var s string;

    fmt.Scan(&n, &c0, &c1, &h, &s);
    var cnt0, cnt1 = 0, 0;
    for i := 0; i < n; i++ {
        if s[i] == '0' {
            cnt0++
        } else {
            cnt1++
        }
    }
    ans := 0
    if c0 > c1 + h {
        ans += h * cnt0
        cnt1 += cnt0
        cnt0 = 0
    }
    if c1 > c0 + h {
        ans += h * cnt1
        cnt0 += cnt1
        cnt1 = 0
    }
    ans += cnt0 * c0 + cnt1 * c1
    fmt.Println(ans)
}

func main() {
    var n int
    fmt.Scan(&n)
    for ;n > 0; n-- {
        solve()
    }
}

package main

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

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

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

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

func solve() {
	var n, c0, c1, h int
	scanf("%d %d %d %d\n", &n, &c0, &c1, &h)
	var s string
	scanf("%s\n", &s)
	ans := 0
	for i := 0; i < len(s); i++ {
		if s[i] == '0' {
			ans += min(c0, h + c1)
		} else {
			ans += min(c1, h + c0)
		}
	}
	printf("%d\n", ans)
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

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

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

	var T, n, c0, c1, h int
	var s []byte
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &c0, &c1, &h, &s)
		if c0 > c1+h {
			c0 = c1 + h
		} else if c1 > c0+h {
			c1 = c0 + h
		}
		b := [2]int{}
		for _, c := range s {
			b[c&1]++
		}
		Fprintln(out, c0*b[0]+c1*b[1])
	}
}

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

package main

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

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, c0, c1, h int
		fmt.Fscan(input, &n, &c0, &c1, &h)

		arr := make([]byte, 0)
		fmt.Fscan(input, &arr)

		ans := 0
		for i := 0; i < n; i++ {
			if arr[i] == '0' {
				ans += c0
			} else {
				ans += c1
			}
		}

		for i := 0; i < n; i++ {
			if arr[i] == '1' && (h+c0) < c1 {
				ans -= c1 - (h + c0)
			}

			if arr[i] == '0' && (h+c1) < c0 {
				ans -= c0 - (h + c1)
			}
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	//rd, _ := os.Open("input")
	//in := bufio.NewReader(rd)
	in := bufio.NewReader(os.Stdin)

	var t, n, c0, c1, h int
	var s string
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &c0, &c1, &h)
		fmt.Fscan(in, &s)
		sum := 0
		if c0 > c1 && c1+h < c0 {
			c0 = c1 + h
		}
		if c1 > c0 && c0+h < c1 {
			c1 = c0 + h
		}
		for i := range s {
			if s[i] == '0' {
				sum += c0
			} else {
				sum += c1
			}
		}
		fmt.Println(sum)
	}
}

package main

import (
	"fmt"
	"math"
)

var t,n,c1,c2,h,ss int
var s string

func main()  {
	fmt.Scan(&t)
	for i:=1;i<=t;i++{
		ss=0
		fmt.Scan(&n,&c1,&c2,&h)
		fmt.Scan(&s)
		if c1==c2{
			fmt.Println(n*c1)
		}else if c1<c2{
			for j:=0;j<len(s);j++{
				if s[j]=='0'{
					ss+=c1
				}else{
					ss+=int(math.Min(float64(c1+h),float64(c2)))
				}
			}
			fmt.Println(ss)
		}else{
			for j:=0;j<len(s);j++{
				if s[j]=='1'{
					ss+=c2
				}else{
					ss+=int(math.Min(float64(c2+h),float64(c1)))
				}
			}
			fmt.Println(ss)
		}
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

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

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

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n, c0, c1, h := sint64(), sint64(), sint64(), sint64()
		s := sstring()
		printf("%d\n", sol(n, c0, c1, h, s))
	}
}

func sol(n, c0, c1, h int64, s string) int64 {
	n0 := int64(0)
	n1 := int64(0)
	for _, r := range s {
		if r == '0' {
			n0++
		} else {
			n1++
		}
	}
	return min((c0*n)+(h*n1), (c1*n)+(h*n0), (c0*n0)+(c1*n1))
}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		var n, c0, c1, h int
		fmt.Scanf("%d%d%d%d", &n, &c0, &c1, &h)
		var s string
		fmt.Scanf("%s", &s)
		oneCnt := 0
		zeroCnt := 0
		for j := range s {
			if s[j] == '1' {
				oneCnt++
			} else {
				zeroCnt++
			}
		}
		if h + c1 < c0 {
			c0 = h + c1
		} else if h + c0 < c1 {
			c1 = h + c0
		}
		fmt.Printf("%d\n", oneCnt * c1 + zeroCnt * c0)
	}
}


This is an interactive problem.We picked an array of whole numbers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 10^9$$$) and concealed exactly one zero in it! Your goal is to find the location of this zero, that is, to find $$$i$$$ such that $$$a_i = 0$$$.You are allowed to make several queries to guess the answer. For each query, you can think up three distinct indices $$$i, j, k$$$, and we will tell you the value of $$$\max(a_i, a_j, a_k) - \min(a_i, a_j, a_k)$$$. In other words, we will tell you the difference between the maximum and the minimum number among $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$.You are allowed to make no more than $$$2 \cdot n - 2$$$ queries, and after that you have two tries to guess where the zero is. That is, you have to tell us two numbers $$$i$$$ and $$$j$$$ and you win if $$$a_i = 0$$$ or $$$a_j = 0$$$.Can you guess where we hid the zero?Note that the array in each test case is fixed beforehand and will not change during the game. In other words, the interactor is not adaptive.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). Description of the test cases follows. The first and only line of each test case contains an integer $$$n$$$ ($$$4 \le n \le 1000$$$) — the length of the array that we picked. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3000$$$.

NoteArray from sample: $$$[1, 2, 0, 3]$$$.

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n := read()
		x, y, z := 1, 2, 3
		Fprintln(out, "?", x, y, z)
		out.Flush()
		lastDiff := read()
		for i := 4; i <= n; i++ {
			Fprintln(out, "?", x, y, i)
			out.Flush()
			curDiff1 := read()
			Fprintln(out, "?", x, z, i)
			out.Flush()
			curDiff2 := read()
			if curDiff1 <= lastDiff && curDiff2 <= lastDiff {
				continue
			}
			if curDiff1 > curDiff2 {
				lastDiff = curDiff1
				z = i
			} else {
				lastDiff = curDiff2
				y = i
			}
		}
		index := 1
		for x == index || y == index || z == index {
			index++
		}
		Fprintln(out, "?", x, y, index)
		out.Flush()
		Diff1 := read()
		Fprintln(out, "?", x, z, index)
		out.Flush()
		Diff2 := read()
		switch lastDiff {
		case Diff1:
			Fprintln(out, "!", x, y)
		case Diff2:
			Fprintln(out, "!", x, z)
		default:
			Fprintln(out, "!", y, z)
		}
		out.Flush()
	}
}

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

package main

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

var test [4]int = [4]int{1, 2, 0, 3}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func react(x, y, z int) {
	Diff := max(test[x-1], max(test[y-1], test[z-1])) - min(test[x-1], min(test[y-1], test[z-1]))
	Println(Diff)
}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	t := read()
	for t > 0 {
		t--
		n := read()
		x, y, z := 1, 2, 3
		Fprintln(out, "?", x, y, z)
		out.Flush()
		lastDiff := read()
		curDiff := 0
		for i := 4; i <= n; i++ {
			Fprintln(out, "?", x, y, i)
			out.Flush()
			curDiff = read()
			if lastDiff <= curDiff {
				lastDiff = curDiff
				z = i
			}
		}
		for i := 1; i <= n; i++ {
			if x == i || y == i || z == i {
				continue
			}
			Fprintln(out, "?", x, i, z)
			out.Flush()
			curDiff = read()
			if lastDiff <= curDiff {
				lastDiff = curDiff
				y = i
			}
		}
		index := -1
		for i := 1; i <= n; i++ {
			if x == i || y == i || z == i {
				continue
			}
			index = i
			break
		}
		Fprintln(out, "?", index, y, z)
		out.Flush()
		curDiff = read()
		if curDiff == lastDiff {
			Fprintln(out, "!", y, z)
		} else {
			Fprintln(out, "?", x, index, z)
			out.Flush()
			curDiff = read()
			if curDiff == lastDiff {
				Fprintln(out, "!", x, z)
			} else {
				Fprintln(out, "!", x, y)
			}
		}
		out.Flush()
	}
}

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

package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func q(i, j, k int) (d int) {
	Println("?", i, j, k)
	Scan(&d)
	return
}

func CF1634D() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		a, b, c := 1, 2, 3
		d := q(1, 2, 3)
		for i := 4; i <= n; i++ {
			x, y := q(a, b, i), q(a, c, i)
			if x <= d && y <= d {
				continue
			}
			if y > x {
				b, d = i, y
			} else if x > d {
				c, d = i, x
			}
		}
		i := 1
		for i == a || i == b || i == c {
			i++
		}
		if q(a, b, i) == d {
			Println("!", a, b)
		} else if q(a, c, i) == d {
			Println("!", a, c)
		} else {
			Println("!", b, c)
		}
	}
}

func main() { CF1634D() }

//package main
//
//import . "fmt"
//
//// github.com/EndlessCheng/codeforces-go
//func q(i, j, k int) (d int) {
//	Println("?", i, j, k)
//	Scan(&d)
//	return
//}
//
//func CF1634D() {
//	var T, n int
//	for Scan(&T); T > 0; T-- {
//		Scan(&n)
//		a, b, c := 1, 2, 3
//		d := q(1, 2, 3)
//		for i := 4; i <= n; i++ {
//			x, y := q(a, b, i), q(a, c, i)
//			if x <= d && y <= d {
//				continue
//			}
//			if y > x {
//				b, d = i, y
//			} else if x > d {
//				c, d = i, x
//			}
//		}
//		i := 1
//		for i == a || i == b || i == c {
//			i++
//		}
//		if q(a, b, i) == d {
//			Println("!", a, b)
//		} else if q(a, c, i) == d {
//			Println("!", a, c)
//		} else {
//			Println("!", b, c)
//		}
//	}
//}
//
//func main() { CF1634D() }
//package main
//
//import . "fmt"
//
//// github.com/EndlessCheng/codeforces-go
//func q(i, j, k int) (d int) {
//	Println("?", i, j, k)
//	Scan(&d)
//	return
//}
//
//func CF1634D() {
//	var T, n int
//	for Scan(&T); T > 0; T-- {
//		Scan(&n)
//		a, b, c := 1, 2, 3
//		d := q(1, 2, 3)
//		for i := 4; i <= n; i++ {
//			x, y := q(a, b, i), q(a, c, i)
//			if x <= d && y <= d {
//				continue
//			}
//			if y > x {
//				b, d = i, y
//			} else if x > d {
//				c, d = i, x
//			}
//		}
//		i := 1
//		for i == a || i == b || i == c {
//			i++
//		}
//		if q(a, b, i) == d {
//			Println("!", a, b)
//		} else if q(a, c, i) == d {
//			Println("!", a, c)
//		} else {
//			Println("!", b, c)
//		}
//	}
//}
//
//func main() { CF1634D() }

package main
import."fmt"

// github.com/EndlessCheng/codeforces-go
func q(i,j,k int)(d int){Println("?",i,j,k);Scan(&d);return}
func main(){
	T,n:=0,0
	for Scan(&T);T>0;T--{
		Scan(&n)
		a,b,c:=1,2,3
		d:=q(1,2,3)
		for i:=4;i<=n;i++{
			x,y:=q(a,b,i),q(a,c,i)
			if x<y{if y>d{b,d=i,y}
			}else if x>d{c,d=i,x}
		}
		i:=1
		for i==a||i==b||i==c{i++}
		if q(a,b,i)==d{Println("!",a,b)
		}else if q(a,c,i)==d{Println("!",a,c)
		}else{Println("!",b,c)}
	}
}

package main

import "fmt"

func query(i, j, k int) (dif int) {
	fmt.Println("?", i, j, k)
	fmt.Scan(&dif)
	return
}

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

	for t != 0 {
		var n, dif int
		fmt.Scan(&n)
		i, j, k := 1, 2, 3

		for nk := k; nk <= n; nk++ {
			cur := query(i, j, nk)
			if cur > dif {
				k = nk
				dif = cur
			}
		}

		for nj := j; nj <= n; nj++ {
			if nj != k {
				cur := query(i, nj, k)
				if cur > dif {
					j = nj
					dif = cur
				}
			}
		}

		for ni := 2; ni <= n; ni++ {
			if ni != j && ni != k {
				cur := query(ni, j, k)
				if cur == dif {
					fmt.Println("!", j, k)
					goto end
				}
				break
			}
		}

		for nj := 2; nj <= n; nj++ {
			if nj != j && nj != k {
				cur := query(i, nj, k)
				if cur == dif {
					fmt.Println("!", i, k)
					goto end
				}
				break
			}
		}

		fmt.Println("!", i, j)
	end:
		t--
	}
}

package main

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

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

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

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

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

// ----------------------------- TEMPLATE END ----------------------------------

const INF = int(1e9 + 10000)

var secret []int = []int{-1, 1, 2, 4, 1, 2, 3, 3, 0, 3, 4}

const DEBUG = false

func ask(a, b, c int) int {
	printf("? %d %d %d\n", a, b, c)
	flush()
	var r int
	if DEBUG {
		r = max(secret[a], max(secret[b], secret[c])) -
			min(secret[a], min(secret[b], secret[c]))
		printf("answer %d\n", r)
		return r
	}
	scan(&r)
	if r == -1 {
		os.Exit(0)
	}
	return r
}

func answer(a, b int) {
	printf("! %d %d\n", a, b)
	flush()
}

var min4 [5][5]int

func solve4() (int, int) {
	var max4 int = 0
	for a := 1; a <= 3; a++ {
		for b := a + 1; b <= 4; b++ {
			min4[a][b] = INF
		}
	}
	for a := 1; a <= 2; a++ {
		for b := a + 1; b <= 3; b++ {
			for c := b + 1; c <= 4; c++ {
				x := ask(a, b, c)
				min4[a][b] = min(min4[a][b], x)
				min4[a][c] = min(min4[a][c], x)
				min4[b][c] = min(min4[b][c], x)
				max4 = max(max4, x)
			}
		}
	}
	for a := 1; a <= 3; a++ {
		for b := a + 1; b <= 4; b++ {
			if min4[a][b] == max4 {
				return a, b
			}
		}
	}
	panic("answer for 4 not found")
}

func solveCase() {
	var n int
	scan(&n)
	a, b := solve4()
	diff := min4[a][b]
	for c := 5; c <= n; c++ {
		mex := 1
		for mex == a || mex == b {
			mex++
		}

		x := ask(a, mex, c)
		y := ask(mex, b, c)
		if x <= diff && y <= diff {
			continue
		}
		if x > y {
			diff = x
			b = c
		} else {
			diff = y
			a = c
		}
	}
	answer(a, b)
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		solveCase()
	}
}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n := read()
		x, y, z := 1, 2, 3
		Fprintln(out, "?", x, y, z)
		out.Flush()
		lastDiff := read()
		for i := 4; i <= n; i++ {
			Fprintln(out, "?", x, y, i)
			out.Flush()
			curDiff1 := read()
			Fprintln(out, "?", x, z, i)
			out.Flush()
			curDiff2 := read()
			if curDiff1 < curDiff2 {
				if lastDiff <= curDiff1 {
					lastDiff = curDiff1
					y = i
				}
			} else {
				if lastDiff <= curDiff2 {
					lastDiff = curDiff2
					z = i
				}
			}
		}
		index := 1
		for x == index || y == index || z == index {
			index++
		}
		Fprintln(out, "?", index, y, z)
		out.Flush()
		Diff1 := read()
		Fprintln(out, "?", x, index, z)
		out.Flush()
		Diff2 := read()
		switch lastDiff {
		case Diff1:
			Fprintln(out, "!", y, z)
		case Diff2:
			Fprintln(out, "!", x, z)
		default:
			Fprintln(out, "!", x, y)
		}
		out.Flush()
	}
}

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

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for t := read(); t > 0; t-- {
		n := read()
		x, y, z := 1, 2, 3
		Fprintln(out, "?", x, y, z)
		out.Flush()
		lastDiff := read()
		for i := 4; i <= n; i++ {
			Fprintln(out, "?", x, i, z)
			out.Flush()
			curDiff1 := read()
			Fprintln(out, "?", x, y, i)
			out.Flush()
			curDiff2 := read()
			if curDiff1 < curDiff2 {
				if lastDiff < curDiff1 {
					lastDiff = curDiff1
					y = i
				}
			} else {
				if lastDiff < curDiff2 {
					lastDiff = curDiff2
					z = i
				}
			}
		}
		index := 1
		for x == index || y == index || z == index {
			index++
		}
		Fprintln(out, "?", index, y, z)
		out.Flush()
		Diff1 := read()
		Fprintln(out, "?", x, index, z)
		out.Flush()
		Diff2 := read()
		Fprintln(out, "?", x, y, index)
		out.Flush()
		Diff3 := read()
		switch lastDiff {
		case Diff1:
			Fprintln(out, "!", y, z)
		case Diff2:
			Fprintln(out, "!", x, z)
		case Diff3:
			Fprintln(out, "!", x, y)
		}
		out.Flush()
	}
}

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

package main

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

var test [4]int = [4]int{1, 2, 0, 3}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	n := read()
	x, y, z := 1, 2, 3
	Fprintln(out, "?", x, y, z)
	out.Flush()
	lastDiff := read()
	curDiff := 0
	for i := 4; i <= n; i++ {
		Fprintln(out, "?", x, y, i)
		out.Flush()
		curDiff = read()
		if lastDiff <= curDiff {
			lastDiff = curDiff
			z = i
		}
	}
	for i := 0; i <= n; i++ {
		if x == i || y == i || z == i {
			continue
		}
		Fprintln(out, "?", x, i, z)
		out.Flush()
		curDiff = read()
		if lastDiff <= curDiff {
			lastDiff = curDiff
			z = i
		}
	}
	index := -1
	for i := 0; i <= n; i++ {
		if x == i || y == i || z == i {
			continue
		}
		index = i
		break
	}
	Fprintln(out, "?", index, y, z)
	out.Flush()
	curDiff = read()
	if curDiff == lastDiff {
		Fprintln(out, "!", y, z)
	} else {
		Fprintln(out, "?", x, index, z)
		out.Flush()
		curDiff = read()
		if curDiff == lastDiff {
			Fprintln(out, "!", x, z)
		} else {
			Fprintln(out, "!", x, y)
		}
	}
	out.Flush()
}

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

package main

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

var test [4]int = [4]int{1, 2, 0, 3}

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	n := read()
	x, y, z := 1, 2, 3
	Fprintln(out, "?", x, y, z)
	out.Flush()
	lastDiff := read()
	curDiff := 0
	for i := 4; i <= n; i++ {
		Fprintln(out, "?", x, y, i)
		out.Flush()
		curDiff = read()
		if lastDiff <= curDiff {
			lastDiff = curDiff
			z = i
		}
	}
	for i := 0; i <= n; i++ {
		if x == i || y == i || z == i {
			continue
		}
		Fprintln(out, "?", x, i, z)
		out.Flush()
		curDiff = read()
		if lastDiff <= curDiff {
			lastDiff = curDiff
			z = i
		}
	}
	index := -1
	for i := 0; i <= n; i++ {
		if x == i || y == i || z == i {
			continue
		}
		index = i
		break
	}
	Fprintln(out, "?", index, y, z)
	out.Flush()
	curDiff = read()
	if curDiff == lastDiff {
		Fprintln(out, "!", x, z)
	} else {
		Fprintln(out, "?", x, y, index)
		out.Flush()
		curDiff = read()
		if curDiff == lastDiff {
			Fprintln(out, "!", x, y)
		} else {
			Fprintln(out, "!", x, z)
		}
	}
	out.Flush()
}

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

package main

import (
	"bufio"
	. "fmt"
	"math/rand"
	"os"
	"time"
)

// github.com/EndlessCheng/codeforces-go
type (
	initData struct{ n int }
	request  struct{ q []int }
	response struct{ v int }
	answer   struct{ ans []int }
)

type interaction interface {
	readInitData() initData
	query(request) response
	printAnswer(answer)
}

type io struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (io io) readInitData() (d initData) {
	Fscan(io.in, &d.n)
	return
}

func (io io) query(q request) (resp response) {
	Fprint(io.out, "?")
	for _, v := range q.q {
		Fprint(io.out, " ", v)
	}
	Fprintln(io.out)
	io.out.Flush()

	Fscan(io.in, &resp.v)
	if resp.v < 0 {
		panic(-1)
	}
	return
}

func (io io) printAnswer(a answer) {
	Fprint(io.out, "!")
	for _, v := range a.ans {
		Fprint(io.out, " ", v)
	}
	Fprintln(io.out)
	io.out.Flush()

	// TODO: Optional
	var res int
	if Fscan(io.in, &res); res < 0 {
		panic(res)
	}
}

func doInteraction(it interaction) {
	dt := it.readInitData()
	n := dt.n

	id := make([]int, n)
	for i := range id {
		id[i] = i + 1
	}
	rand.Shuffle(len(id), func(i, j int) { id[i], id[j] = id[j], id[i] })
	q := func(q ...int) int { return it.query(request{[]int{id[q[0]-1], id[q[1]-1], id[q[2]-1]}}).v }

	ans := []int{}
	defer func() { it.printAnswer(answer{ans}) }()

	var d0, st int

	for i := 1; i+2 <= n && d0 == 0; i += 3 {
		d0 = q(i, i+1, i+2)
		st = i
	}
	if d0 == 0 {
		d0 = q(n-2, n-1, n)
		st = n - 2
	}

	f := func(a, b, c, d0 int) (x, y, dd int) {
		o := 1
		for o == a || o == b || o == c {
			o++
		}

		d12 := q(a, b, o)
		d13 := q(a, c, o)
		d23 := q(b, c, o)

		if d12 > d0 || d13 > d0 || d23 > d0 {
			if d12 < d13 && d12 < d23 {
				x, y = c, o
				dd = d13
			} else if d13 < d12 && d13 < d23 {
				x, y = b, o
				dd = d12
			} else {
				x, y = a, o
				dd = d12
			}
		} else {
			if d12 >= d13 && d12 >= d23 {
				x, y = a, b
				dd = d12
			} else if d13 >= d12 && d13 >= d23 {
				x, y = a, c
				dd = d13
			} else {
				x, y = b, c
				dd = d23
			}
		}
		return
	}

	x,y,dd := f(st,st+1,st+2,d0)

	for i := st + 3; i <= n; i++ {
		if d2 := q(x, y, i);d2 > dd {
			x,y,dd = f(x,y,i, d2)
		}
	}

	ans = []int{id[x-1], id[y-1]}
	//if d12 <= d0 {
	//
	//} else {
	//
	//}

	//d012 := q(id[0], id[1], id[2])
	//
	//for i := 3; i < n; i++ {
	//	d01i := q(id[0], id[1], id[i])
	//	d02i := q(id[0], id[2], id[i])
	//	if d01i == d02i {
	//
	//	}
	//	if d01i > d012 && d02i > d012 {
	//		var x, y int
	//		if d01i > d02i {
	//			x, y = 0, 1
	//		} else {
	//			x, y = 0, 2
	//		}
	//
	//	}
	//}

	//for {
	//	type pair struct{ i0, d int }
	//	res := []pair{}
	//	for i := 0; i < n; i += 3 {
	//		res = append(res, pair{i, q(id[i], id[(i+1)%n], id[(i+2)%n])})
	//	}
	//	sort.Slice(res, func(i, j int) bool { return res[i].d > res[j].d })
	//
	//
	//
	//}
}

// TODO: check output format before submit
func run() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	rand.Seed(time.Now().UnixNano())

	T := 1
	Fscan(in, &T) //
	for ; T > 0; T-- {
		doInteraction(io{in, out})
	}
}

func main() { run() }


After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency.These were the great news for Alice, whose grandfather got into Bitcoin mining in 2013, and accumulated a lot of them throughout the years. Unfortunately, when paying something in bitcoin everyone can see how many bitcoins you have in your public address wallet. This worried Alice, so she decided to split her bitcoins among multiple different addresses, so that every address has at most $$$x$$$ satoshi (1 bitcoin = $$$10^8$$$ satoshi). She can create new public address wallets for free and is willing to pay $$$f$$$ fee in satoshi per transaction to ensure acceptable speed of transfer. The fee is deducted from the address the transaction was sent from. Tell Alice how much total fee in satoshi she will need to pay to achieve her goal.

First line contains number $$$N$$$ ($$$1 \leq N \leq 200\,000$$$) representing total number of public addresses Alice has. Next line contains $$$N$$$ integer numbers $$$a_i$$$ ($$$1 \leq a_i \leq 10^9$$$) separated by a single space, representing how many satoshi Alice has in her public addresses. Last line contains two numbers $$$x$$$, $$$f$$$ ($$$1 \leq f < x \leq 10^9$$$) representing maximum number of satoshies Alice can have in one address, as well as fee in satoshies she is willing to pay per transaction.

Output one integer number representing total fee in satoshi Alice will need to pay to achieve her goal.

NoteAlice can make two transactions in a following way:0. 13 7 6 (initial state)1. 6 7 6 5 (create new address and transfer from first public address 5 satoshies)2. 6 4 6 5 1 (create new address and transfer from second address 1 satoshi)Since cost per transaction is 2 satoshies, total fee is 4.

package main

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

var stdin = bufio.NewScanner(os.Stdin)

func readInt() int64 {
	stdin.Scan()
	i, _ := strconv.ParseInt(stdin.Text(), 10, 64)
	return i
}

func main() {
	stdin.Split(bufio.ScanWords)
	n := int(readInt())
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}
	m := readInt()
	f := readInt()
	var transferCount int64
	cost := m + f
	for i := 0; i < n; i++ {
		if a[i]-m < 0 {
			continue
		}
		transferCount += (a[i] - m) / cost
		if (a[i]-m)%cost != 0 {
			transferCount++
		}
	}
	fmt.Println(transferCount * f)
}

package main

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

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

func ReadInt64() int64 {
    scanner.Scan()
    ans, _ := strconv.ParseInt(scanner.Text(),10,64)
    return ans
}

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

func PrintInts(ints ...int64) {
    for _, value := range ints {
        writer.WriteString(strconv.FormatInt(value, 10))
        writer.WriteByte(' ')
    }
}

// func PrintInts64(ints ...int64) {
//     for _, value := range ints {
//         writer.WriteString(strconv.FormatInt(value,64))
//         writer.WriteByte(' ')
//     }
// }

func main() {
	defer writer.Flush()
    scanner.Split(bufio.ScanWords)

    n := ReadInt32()

	v := make([]int64, n)

	for i := 0; i < n; i++ {
		v[i] = ReadInt64()
	}

    x, f := ReadInt64(), ReadInt64()

    resp := int64(0)

	for _,elem := range v {
		if elem > x {
			resp += (elem - x -1) / (x+f) + 1
		}
	}

	PrintInts(resp*f)
}

package main

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

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() {
  defer writer.Flush()

  var N,x,f,i,count int64

  scanf("%d\n", &N)
  line, _ := reader.ReadString('\n')
  scanf("%d %d\n", &x, &f)
  line = strings.TrimSuffix(line, "\r\n")
  mm := strings.Split(line, " ")
  count = 0
  for i = 0 ; i<N ; i++ {
      money,_ := strconv.ParseInt(mm[i], 10, 64)
      if money > x {
          var t int64
          if (money-x)%(x+f) == 0 {
              t = 0
          }else{
              t = 1
          }
          count += (money-x)/(x+f)+t
      }
  }
  printf("%d\n", count*f)

}

package main

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

var stdin = bufio.NewScanner(os.Stdin)

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

func main() {
	stdin.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}
	m := readInt()
	f := readInt()
	var transferCount int
	cost := m + f
	for i := 0; i < n; i++ {
		if a[i]-m < 0 {
			continue
		}
		transferCount += (a[i] - m) / cost
		if (a[i]-m)%cost != 0 {
			transferCount++
		}
	}
	fmt.Println(transferCount * f)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var m, f int64
	fmt.Scanf("%d\n", &n)
	a := make([]int64, n)
	for i := 0; i < n-1; i++ {
		fmt.Scanf("%d", &a[i])
	}
	fmt.Scanf("%d\n", &a[n-1])
	fmt.Scanf("%d %d", &m, &f)
	var transferCount int64
	cost := m + f
	for i := 0; i < n; i++ {
		transferCount += (a[i] - m) / cost
		if (a[i]-m)%cost != 0 {
			transferCount++
		}
	}
	fmt.Println(transferCount * f)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var m, f int64
	fmt.Scanf("%d\n", &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	fmt.Scanf("%d %d", &m, &f)
	var transferCount int64
	for i := 0; i < n; i++ {
		transferCount += int64(math.Ceil(float64(a[i]-m) / float64(m+f)))
	}
	fmt.Println(transferCount * f)
}

package main

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

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() {
	defer writer.Flush()
	var n int
	scanf("%d", &n)

	var v = make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &v[i])
	}

	var x, f int

	scanf("%d %d", &x, &f)

	resp := 0

	for _,elem := range v {
		if elem > x {
			if elem < x + f {
				resp += f
			} else {
				resp += f * ((elem/(x+f)))
			}
		}
	}

	printf("%d\n", resp)
}

package main

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

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() {
	var n int
	scanf("%d", &n)

	var v = make([]int, n)

	for i := 0; i < n; i++ {
		scanf("%d", &v[i])
	}

	var x, f int

	scanf("%d %d", &x, &f)

	resp := 0

	for _,elem := range v {
		if elem > x {
			if elem < x + f {
				resp += f
			} else {
				resp += f * ((elem/(x+f)))
			}
		}
	}

	fmt.Println(resp)
}

package main

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

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

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

func PrintInts(ints ...int) {
    for _, value := range ints {
        writer.WriteString(strconv.Itoa(value))
        writer.WriteByte(' ')
    }
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)

    n := ReadInt32()

	v := make([]int, n)

	for i := 0; i < n; i++ {
		v[i] = ReadInt32()
	}

    x, f := ReadInt32(), ReadInt32()

    resp := 0

	for _,elem := range v {
		if elem > x {
			if elem < x + f {
				resp += f
			} else {
				resp += f * ((elem/(x+f)))
			}
		}
	}

	PrintInts(resp)

}

package main

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

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

func ReadInt64() int64 {
    scanner.Scan()
    ans, _ := strconv.ParseInt(scanner.Text(),10,64)
    return ans
}

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

func PrintInts(ints ...int64) {
    for _, value := range ints {
        writer.WriteString(strconv.FormatInt(value, 10))
        writer.WriteByte(' ')
    }
}

// func PrintInts64(ints ...int64) {
//     for _, value := range ints {
//         writer.WriteString(strconv.FormatInt(value,64))
//         writer.WriteByte(' ')
//     }
// }

func main() {
	defer writer.Flush()
    scanner.Split(bufio.ScanWords)

    n := ReadInt32()

	v := make([]int64, n)

	for i := 0; i < n; i++ {
		v[i] = ReadInt64()
	}

    x, f := ReadInt64(), ReadInt64()

    resp := int64(0)

	for _,elem := range v {
		if elem > x {
			if elem < x + f {
				resp += f
			} else {
				resp += f * ((elem/(x+f)))
			}
		}
	}

	PrintInts(resp)
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
// var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt64() int64 {
    scanner.Scan()
    ans, _ := strconv.ParseInt(scanner.Text(),10,64)
    return ans
}

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

// func PrintInts(ints ...int) {
//     for _, value := range ints {
//         writer.WriteString(strconv.Itoa(value))
//         writer.WriteByte(' ')
//     }
// }

// func PrintInts64(ints ...int64) {
//     for _, value := range ints {
//         writer.WriteString(strconv.FormatInt(value,64))
//         writer.WriteByte(' ')
//     }
// }

func main() {
    scanner.Split(bufio.ScanWords)

    n := ReadInt32()

	v := make([]int64, n)

	for i := 0; i < n; i++ {
		v[i] = ReadInt64()
	}

    x, f := ReadInt64(), ReadInt64()

    resp := int64(0)

	for _,elem := range v {
		if elem > x {
			if elem < x + f {
				resp += f
			} else {
				resp += f * ((elem/(x+f)))
			}
		}
	}

	// PrintInts64(resp)
	fmt.Println(resp)
}

package main

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

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() {
  defer writer.Flush()

  var N,x,f int

  scanf("%d\n", &N)
  line, _ := reader.ReadString('\n')
  scanf("%d %d\n", &x, &f)
  mm := strings.Split(line, " ")
  count := 0
  for i := 0 ; i<N ; i++ {
      money,_ := strconv.Atoi(mm[i])
      if money > x {
          var t int
          if (money-x)%(x+f) == 0 {
              t = 0
          }else{
              t = 1
          }
          count += (money-x)/(x+f)+t
      }
  }
  printf("%d\n", count*f)

}

package main

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

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() {
  defer writer.Flush()

  var N,x,f,i,count int64

  scanf("%d\n", &N)
  line, _ := reader.ReadString('\n')
  scanf("%d %d\n", &x, &f)
  mm := strings.Split(line, " ")
  count = 0
  for i = 0 ; i<N ; i++ {
      money,_ := strconv.ParseInt(mm[i], 10, 64)
      if money > x {
          var t int64
          if (money-x)%(x+f) == 0 {
              t = 0
          }else{
              t = 1
          }
          count += (money-x)/(x+f)+t
      }
  }
  printf("%d\n", count*f)

}

package main

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

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() {
  defer writer.Flush()

  var N,x,f,i,count int64

  scanf("%d\n", &N)
  line, _ := reader.ReadString('\n')
  scanf("%d %d\n", &x, &f)
  line = strings.TrimSuffix(line, "\r\n")
  mm := strings.Split(line, " ")
  count = 0
  for i = 0 ; i<N ; i++ {
      printf("%s\n",mm[i])
      money,_ := strconv.ParseInt(mm[i], 10, 64)
      if money > x {
          var t int64
          if (money-x)%(x+f) == 0 {
              t = 0
          }else{
              t = 1
          }
          count += (money-x)/(x+f)+t
      }
  }
  printf("%d\n", count*f)

}


The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular n-gon. They are numbered in clockwise order with numbers from 1 to n.The site of the University has already conducted a voting that estimated each sculpture's characteristic of ti — the degree of the sculpture's attractiveness. The values of ti can be positive, negative or zero.When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that:   the remaining sculptures form a regular polygon (the number of vertices should be between 3 and n),  the sum of the ti values of the remaining sculptures is maximized. Help the Vice Rector to analyze the criticism — find the maximum value of ti sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.

The first input line contains an integer n (3 ≤ n ≤ 20000) — the initial number of sculptures. The second line contains a sequence of integers t1, t2, ..., tn, ti — the degree of the i-th sculpture's attractiveness ( - 1000 ≤ ti ≤ 1000). The numbers on the line are separated by spaces.

Print the required maximum sum of the sculptures' attractiveness.

NoteIn the first sample it is best to leave every second sculpture, that is, leave sculptures with attractivenesses: 2, 4, 5 и 3.

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	value :=make([]int64,n)
	for k:=0;k<n;k++ {
		fmt.Scan(&value[k])
	}
	var output,cm int64 =0,-30000000
	for d:=1;d<=n/3;d++ {
		if n%d!=0 {
			continue
		}
		for r:=0;r<d;r++ {
			output=0
			for k:=0;k<n/d;k++ {
				output +=value[d*k+r]

			}
			if output > cm {
					cm = output
			}
		}
	}
	fmt.Println(cm)

}

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n+1)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  max := -20000000
  for i := 1; i <= n/3; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < i; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
      }
      max = int(math.Max(float64(max), float64(sum)))
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

import "fmt"

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

func main() {
    var n int
    var t [20005]int
    fmt.Scan(&n)
    sum := 0
    for i := 1; i <= n; i++ {
        fmt.Scan(&t[i])
        sum += t[i]
    }
    for k := 2; k <= (n/3); k++ {
        if (n%k) == 0 {
            for a := 1; a <= k; a++ {
                newsum := 0
                for i := a; i <= n; i += k {
                    newsum += t[i]
                }
                sum = max(sum,newsum)
            }
        }
    }
    fmt.Println(sum)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	value := make([]int64, n)
	for k := 0; k < n; k++ {
		fmt.Scan(&value[k])
	}
	var output, cm int64 = 0, -30000000
	for d := 1; d <= n/3; d++ {
		if n%d != 0 {
			continue
		}
		for r := 0; r < d; r++ {
			output = 0
			for k := 0; k < n/d; k++ {
				output += value[d*k+r]

			}
			if output > cm {
				cm = output
			}
		}
	}
	fmt.Println(cm)

}

package main

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

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

	an := make([]int, n, n)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	sum := 0
	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
		sum += an[i]
	}

	ans := sum
	jmp := 2
	for jmp = 2; jmp*3 <= n; jmp++ {
		if n%jmp != 0 {
			continue
		}
		for j := 0; j < jmp; j++ {
			sum = 0
			for i := j; i < n; i += jmp {
				sum += an[i]
			}
			if sum > ans {
				ans = sum
			}
		}
	}

	fmt.Println(ans)
}

package main
import (
	"fmt"
)
func main() {
	var n int
	fmt.Scan(&n)
	value :=make([]int64,n)
	for k:=0;k<n;k++ {
		fmt.Scan(&value[k])
	}
	var output,cm int64 =0,-30000000
	for d:=1;d<=n/3;d++ {
		if n%d!=0 {
			continue
		}
		for r:=0;r<d;r++ {
			output=0
			for k:=0;k<n/d;k++ {
				output +=value[d*k+r]
				if output > cm {
					cm = output
				}
			}
		}
	}
	fmt.Println(cm)

}

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  lastP := 1
  for n/lastP > 3 && n%lastP == 0 {
    lastP++
    //fmt.Printf("lastP: %d\n", lastP)
  }

  max := -20000000
  for i := 1; i <= lastP; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < lastP; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
        max = int(math.Max(float64(max), float64(sum)))
      }
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  lastP := 1
  for n/lastP >= 3 && n%lastP == 0 {
    lastP++
  }

  if !(n/lastP >= 3 && n%lastP == 0) {
    lastP--
  }

  //fmt.Printf("lastP: %d\n", lastP)

  max := -20000000
  for i := 1; i <= lastP; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < lastP; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
      }
      max = int(math.Max(float64(max), float64(sum)))
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n+1)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  lastP := 1
  for n/lastP >= 3 && n%lastP == 0 {
    lastP++
  }

  if !(n/lastP >= 3 && n%lastP == 0) {
    lastP--
  }

  fmt.Printf("lastP: %d\n", lastP)

  max := -20000000
  for i := 1; i <= lastP; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < lastP; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
      }
      max = int(math.Max(float64(max), float64(sum)))
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n+1)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  lastP := 1
  for n/lastP >= 3 && n%lastP == 0 {
    lastP++
  }

  if !(n/lastP >= 3 && n%lastP == 0) {
    lastP--
  }

  if n == 18480 {
    fmt.Printf("lastP: %d\n", lastP)
  }

  max := -20000000
  for i := 1; i <= lastP; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < lastP; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
      }
      max = int(math.Max(float64(max), float64(sum)))
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

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

var in = bufio.NewScanner(os.Stdin)

func init() {
  in.Split(bufio.ScanWords)
}

func main() {
  n := readInt()

  t := make([]int, n+1)
  for i := 0; i < n; i++ {
    t[i] = readInt()
  }

  max := -20000000
  for i := 1; i <= n/3; i++ {
    if n%i != 0 {
      continue
    }
    for j := 0; j < n/3; j++ {
      sum := 0
      for k := j; k < n; k += i {
        sum += t[k]
      }
      max = int(math.Max(float64(max), float64(sum)))
    }
  }

  fmt.Printf("%d\n", max)
}

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

package main

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

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

	an := make([]int, n, n)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	sum := 0
	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
		sum += an[i]
	}

	ans := sum
	jmp := 2
	for jmp*3 <= n {
		for j := 0; j < jmp; j++ {
			sum = 0
			for i := j; i < n; i += jmp {
				sum += an[i]
			}
			if sum > ans {
				ans = sum
			}
		}
		jmp *= 2
	}

	fmt.Println(ans)
}


You are given a string $$$s$$$ of length $$$n$$$ consisting only of lowercase Latin letters.A substring of a string is a contiguous subsequence of that string. So, string "forces" is substring of string "codeforces", but string "coder" is not.Your task is to calculate the number of ways to remove exactly one substring from this string in such a way that all remaining characters are equal (the number of distinct characters either zero or one).It is guaranteed that there is at least two different characters in $$$s$$$.Note that you can remove the whole string and it is correct. Also note that you should remove at least one character.Since the answer can be rather large (not very large though) print it modulo $$$998244353$$$.If you are Python programmer, consider using PyPy instead of Python when you submit your code.

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$. The second line of the input contains the string $$$s$$$ of length $$$n$$$ consisting only of lowercase Latin letters. It is guaranteed that there is at least two different characters in $$$s$$$.

Print one integer — the number of ways modulo $$$998244353$$$ to remove exactly one substring from $$$s$$$ in such way that all remaining characters are equal.

NoteLet $$$s[l; r]$$$ be the substring of $$$s$$$ from the position $$$l$$$ to the position $$$r$$$ inclusive.Then in the first example you can remove the following substrings:   $$$s[1; 2]$$$;  $$$s[1; 3]$$$;  $$$s[1; 4]$$$;  $$$s[2; 2]$$$;  $$$s[2; 3]$$$;  $$$s[2; 4]$$$. In the second example you can remove the following substrings:   $$$s[1; 4]$$$;  $$$s[1; 5]$$$;  $$$s[1; 6]$$$;  $$$s[1; 7]$$$;  $$$s[2; 7]$$$;  $$$s[3; 7]$$$. In the third example you can remove the following substrings:   $$$s[1; 1]$$$;  $$$s[1; 2]$$$;  $$$s[2; 2]$$$.

package main

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

func readln(r *bufio.Reader) (string, error) {
	isPrefix := true
	var err error
	var line, ln []byte
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	stdin := bufio.NewReader(os.Stdin)
	readln(stdin)
	t, _ := readln(stdin)
	var frontRepeating = int64(len(t))
	var backRepeating = int64(len(t))
	for i := 0; i < len(t); i++ {
		if t[i] != t[0] {
			frontRepeating = int64(i)
			break
		}
	}
	for i := 0; i < len(t); i++ {
		if t[len(t)-i-1] != t[len(t)-1] {
			backRepeating = int64(i)
			break
		}
	}
	if frontRepeating == int64(len(t)) {
		fmt.Println(((1 + frontRepeating) * frontRepeating / 2) % 998244353)
	} else if t[0] == t[len(t)-1] {
		fmt.Println(((frontRepeating + 1) * (backRepeating + 1)) % 998244353)
	} else {
		fmt.Println((frontRepeating + backRepeating + 1) % 998244353)
	}
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int

	var str string
	fmt.Fscanf(buf, "%d\n", &t)
	fmt.Fscanf(buf, "%s", &str)
	bstr := []byte(str)
	var l int64 = 0
	var r int64 = int64(t-1)
	for bstr[l] == bstr[l+1] {
		l++
	}
	for bstr[r] == bstr[r-1] {
		r--
	}
//	fmt.Printf("l=%d %d\n",l,r)
	var ans int64 = 0
	var mod int64 = 998244353
	if bstr[0] == bstr[t-1]{
		ans = ((l+2)*(int64(t)-r+1))%mod
	}else{
		ans = (ans+l+1)%mod
		ans = (ans+(int64(t)-r)+1)%mod
	}
	fmt.Printf("%d\n",ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	s := ""
	fmt.Fscanf(in, "%s\n", &s)
	a := make([]int, 26)
	for i := 0; i < n; i++ {
		a[int(s[i])-'a']++
	}
	diff := 0
	for i := 0; i < 26; i++ {
		if a[i] > 0 {
			diff++
		}
	}
	r := n - 1
	l := n - 1
	ans := 0
	//fmt.Println(a)
	used := make([]bool, n)
	for r >= 0 {
		for true {
			if l < 0 {
				break
			}
			if !used[l] {
				a[s[l]-'a']--
				if a[s[l]-'a'] == 0 {
					diff--
				}
				used[l] = true
			}
			if diff == 1 {
				break
			}
			l--
		}
		ans += l + 1
		//fmt.Println(l, r, ans, diff)
		//fmt.Println(a)
		ans %= 998244353
		r--
		a[s[r+1]-'a']++
		if a[s[r+1]-'a'] == 1 {
			diff++
		}
		if l > r {
			l = r
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

package main

import(
	"fmt"
)

func main() {

	var n int64

	mod := int64(998244353)

	fmt.Scan(&n)

	var str string
	fmt.Scan(&str)

	// pontas diferentes
	if str[0] != str[len(str)-1] {
		resp := int64(3)

		for i := 1; i < len(str); i++ {
			if str[i] == str[0] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		for i := len(str)-2; i >= 0; i-- {
			if str[i] == str[len(str)-1] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		fmt.Println(resp%mod)
		return
	}

	// pontas iguais

	resp := int64(2)

	left := int64(0)
	right := int64(0)

	for i := 0; i < len(str); i++ {
		if str[i] == str[0] {
			resp++
			left++
			resp %= mod
		} else {
			break
		}
	}

	for i := len(str)-1; i >= 0; i-- {
		if str[i] == str[len(str)-1] {
			resp++
			right++
			resp %= mod
		} else {
			break
		}
	}

	resp += ( ((left)%mod) * ((right-1)%mod) )%mod
	resp += left-1

	fmt.Println(resp%mod)
}

package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdin.ReadLine()
	l, _, _ := stdin.ReadLine()
	t := string(l)
	var frontRepeating = int64(len(t))
	var backRepeating = int64(len(t))
	for i := 0; i < len(t); i++ {
		if t[i] != t[0] {
			frontRepeating = int64(i)
			break
		}
	}
	for i := 0; i < len(t); i++ {
		if t[len(t)-i-1] != t[len(t)-1] {
			backRepeating = int64(i)
			break
		}
	}
	if t[0] == t[len(t)-1] {
		fmt.Println(((frontRepeating + 1) * (backRepeating + 1)) % 998244353)
	} else {
		fmt.Println((frontRepeating + backRepeating + 1) % 998244353)
	}
}

package main

import(
	"fmt"
)

func main() {

	var n int

	mod := 998244353

	fmt.Scan(&n)

	var str string
	fmt.Scan(&str)

	// pontas diferentes
	if str[0] != str[len(str)-1] {
		resp := 3

		for i := 1; i < len(str); i++ {
			if str[i] == str[0] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		for i := len(str)-2; i >= 0; i-- {
			if str[i] == str[len(str)-1] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		fmt.Println(resp%mod)
		return
	}

	// pontas iguais

	resp := 2

	left := 0
	right := 0

	for i := 0; i < len(str); i++ {
		if str[i] == str[0] {
			resp++
			left++
			resp %= mod
		} else {
			break
		}
	}

	for i := len(str)-1; i >= 0; i-- {
		if str[i] == str[len(str)-1] {
			resp++
			right++
			resp %= mod
		} else {
			break
		}
	}

	resp += ( ((left-1)%mod) * ((right)%mod) )%mod
	resp += ( ((left)%mod) * ((right-1)%mod) )%mod

	fmt.Println(resp)
}

package main

import(
	"fmt"
)

func main() {

	var n int64

	mod := int64(998244353)

	fmt.Scan(&n)

	var str string
	fmt.Scan(&str)

	// pontas diferentes
	if str[0] != str[len(str)-1] {
		resp := int64(3)

		for i := 1; i < len(str); i++ {
			if str[i] == str[0] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		for i := len(str)-2; i >= 0; i-- {
			if str[i] == str[len(str)-1] {
				resp++
				resp %= mod
			} else {
				break
			}
		}

		fmt.Println(resp%mod)
		return
	}

	// pontas iguais

	resp := int64(2)

	left := int64(0)
	right := int64(0)

	for i := 0; i < len(str); i++ {
		if str[i] == str[0] {
			resp++
			left++
			resp %= mod
		} else {
			break
		}
	}

	for i := len(str)-1; i >= 0; i-- {
		if str[i] == str[len(str)-1] {
			resp++
			right++
			resp %= mod
		} else {
			break
		}
	}

	resp += ( ((left-1)%mod) * ((right)%mod) )%mod
	resp += ( ((left)%mod) * ((right-1)%mod) )%mod

	fmt.Println(resp)
}