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 (
	"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 (
	"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
	}
}


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


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() }


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

}


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


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


package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    a := make([]int,m)
    for i := 0; i < m; i++ { fmt.Scan(&a[i]) }
    sort.Ints(a)
    ans := true
    if m == 0 {
        ans = true
    } else if (a[0] == 1) || (a[m-1] == n) {
        ans = false
    } else {
        for i := 2; i < m; i++ {
            if a[i]-2 == a[i-2] {
                ans = false
                break
            }
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)

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

	sort.Ints(arr)

	run := 1
	maxrun := 1
	for i:=1; i<m; i++ {
		if arr[i] == arr[i-1]+1 {
			run++
		} else {
			if run > maxrun {
				maxrun = run
			}
			run = 1
		}
	}

	if run > maxrun {
		maxrun = run
	}

	if maxrun > 2 || (m >= 1 && (arr[len(arr)-1] == n || arr[0] == 1)) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

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

type Scanner struct {
	r            io.Reader
	split        bufio.SplitFunc
	maxTokenSize int
	token, buf   []byte
	start, end   int
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        bufio.ScanWords,
		maxTokenSize: 16777216,
		buf:          make([]byte, 4096),
	}
}

func (s *Scanner) advance(n int) bool {
	if n < 0 || n > s.end-s.start {
		return false
	}
	s.start += n
	return true
}

func (s *Scanner) Text() string {
	return string(s.token)
}

func (s *Scanner) Scan() bool {
	for {
		if s.end > s.start {
			advance, token, err := s.split(s.buf[s.start:s.end], false)
			if err != nil || !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				return true
			}
		}
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		if s.end == len(s.buf) {
			if len(s.buf) >= s.maxTokenSize {
				return false
			}
			newSize := len(s.buf) * 2
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		for loop := 0; ; {
			n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if n > 0 {
				break
			}
			loop++
			if loop > 100 {
				break
			}
		}
	}
}

func (s *Scanner) Split(split bufio.SplitFunc) {
	s.split = split
}

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var sc *Scanner = NewScanner(os.Stdin)

func next() string { sc.Scan(); return sc.Text() }

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

func ni64() int64 {
	sc.Scan()
	n, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return n
}

func pri32(i ...int) {
	for _, ii := range i {
		w.WriteString(strconv.Itoa(ii))
		sp()
	}
}
func pri64(i ...int64) {
	for _, ii := range i {
		w.WriteString(strconv.FormatInt(ii, 10))
		sp()
	}
}
func sp()   { w.WriteByte(' ') }
func endl() { w.WriteByte('\n') }

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

func max(i, j int64) int64 {
	if i > j {
		return i
	}
	return j
}

func main() {
	defer w.Flush()
	n, m := ni32(), ni32()
	if m == 0 {
		w.WriteString("YES\n")
		return
	}
	d := make([]int, m)
	for i := 0; i < m; i++ {
		d[i] = ni32()
	}
	sort.Ints(d)
	if d[0] == 1 || d[m-1] == n {
		w.WriteString("NO\n")
		return
	}
	for i := 2; i < m; i++ {
		if d[i] == d[i-2]+2 {
			w.WriteString("NO\n")
			return
		}
	}
	w.WriteString("YES\n")
}

// 362B-mic
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    a := make([]int, k)
    b := true
    for i := 0; i < k; i++ {
        fmt.Scan(&a[i])
    }
    sort.Sort(sort.IntSlice(a))
    if k != 0 && (a[0] == 1 || a[k-1] == n) {
        b = false
    }
    for i := 2; i < k; i++ {
        if a[i-1] == a[i]-1 && a[i-2] == a[i-1]-1 {
            b = false
        }
    }
    if b {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }

}

package main

import "fmt"

func main() {
	var i,  n, m int
	fmt.Scan(&m, &n)
	p := make(map[int]bool)
	for n > 0 {
		n--
		fmt.Scan(&i)
		p[i] = true
	}
	if p[1] || p[m] {
		fmt.Print("NO")
		return
	}
	for i, _ := range p {
		if p[i+1] && p[i+2] {
			fmt.Print("NO")
			return
		}
	}
	fmt.Print("YES")
}

package main
import (
	"fmt"
	"sort"
	//"unicode/utf8"
)
func main() {
	var n,m int
	flag:= false
	fmt.Scan(&n,&m)
	a:=make([]int,m+1)
	if m>0 {
	for i:=1;i<=m;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	//for i:=0;i<=m;i++ {
		//fmt.Println(a[i])
	//}
	if a[1]==1 || a[m]==n {
		flag=true
	}
	for i:=1;i+2<=m;i++ {
		if a[i]==a[i+1]-1 && a[i]==(a[i+2]-2) {
			flag=true
		}
	}
	}
	if flag == true {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)

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

	sort.Ints(arr)

	run := 1
	maxrun := 1
	for i:=1; i<m; i++ {
		if arr[i] == arr[i-1]+1 {
			run++
		} else {
			if run > maxrun {
				maxrun = run
			}
			run = 1
		}
	}

	if run > maxrun {
		maxrun = run
	}

	if maxrun > 2 || (m > 1 && arr[len(arr)-1] == m) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)

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

	sort.Ints(arr)

	run := 1
	maxrun := 1
	for i:=1; i<m; i++ {
		if arr[i] == arr[i-1]+1 {
			run++
		} else {
			if run > maxrun {
				maxrun = run
			}
			run = 1
		}
	}

	if run > maxrun {
		maxrun = run
	}

	if maxrun > 2 || (m >= 1 && arr[len(arr)-1] == n) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)

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

	sort.Ints(arr)

	run := 1
	maxrun := 1
	for i:=1; i<m; i++ {
		if arr[i] == arr[i-1]+1 {
			run++
		} else {
			if run > maxrun {
				maxrun = run
			}
			run = 1
		}
	}

	if run > maxrun {
		maxrun = run
	}

	if maxrun > 2 || (m > 1 && arr[len(arr)-1] == n) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import "fmt"

func main() {
    var i,  n, m int
    fmt.Scanf("%d %d", &m, &n)
    p := make(map[int]bool)
    for n > 0 {
        n--
        fmt.Scanf("&d", &i)
        p[i] = true
    }
    if p[1] || p[m] {
        fmt.Print("NO")
        return
    }
    for i, _ := range p {
        if p[i+1] && p[i+2] {
            fmt.Print("NO")
            return
        }
    }
    fmt.Print("YES")
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)

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

	var count int64
	for i := 1; i < n; i++ {
		count += abs(arr[i] - arr[i-1])
	}

	fmt.Println(int64(abs(arr[0])) + count)
}

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

package main

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

func abs(v int64) int64 {
    if v < 0 {
        return -v
    }
    return v
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)
    curr := int64(0)
    res := int64(0)

    for i := 0; i < n; i++ {
        var b int64
        fmt.Fscan(stdin, &b)
        res += abs(b-curr)
        curr = b
    }
    fmt.Println(res)
}

package main

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

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

	steps := int64(0)
	current_value := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if a != current_value {
			steps += int64(abs(a - current_value))
			current_value = a
		}
	}

	fmt.Println(steps)
}

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

package main

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

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

	steps := 0
	current_value := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if a != current_value {
			steps += abs(a - current_value)
			current_value = a
		}
	}

	fmt.Println(steps)
}

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)

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

	var count int64
	for i := 1; i < n; i++ {
		count += abs(arr[i] - arr[i-1])
	}

	fmt.Println(int64(arr[0]) + count)
}

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)

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

	var count int
	for i := 1; i < n; i++ {
		count += abs(arr[i] - arr[i-1])
	}

	fmt.Println(arr[0] + count)
}

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