← Home
For problem statement at 2000-2999/2100-2199/2160-2169/2165/problemA.txt this is a correct solution, but verifier at 2000-2999/2100-2199/2160-2169/2165/verifierA.go ends with All 139 tests passed. can you fix the verifier? ```go
package main

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

var scanner *bufio.Scanner

func nextInt() (int64, bool) {
	if !scanner.Scan() {
		return 0, false
	}
	var res int64
	for _, b := range scanner.Bytes() {
		res = res*10 + int64(b-'0')
	}
	return res, true
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1024*1024), 10*1024*1024)

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	t64, ok := nextInt()
	if !ok {
		return
	}
	t := int(t64)

	var a []int64

	for i := 0; i < t; i++ {
		n64, _ := nextInt()
		n := int(n64)

		if cap(a) < n {
			a = make([]int64, n)
		} else {
			a = a[:n]
		}

		var maxA int64 = -1

		for j := 0; j < n; j++ {
			a[j], _ = nextInt()
			if a[j] > maxA {
				maxA = a[j]
			}
		}

		var totalCost int64 = 0
		for j := 0; j < n; j++ {
			next := j + 1
			if next == n {
				next = 0
			}
			if a[j] > a[next] {
				totalCost += a[j]
			} else {
				totalCost += a[next]
			}
		}

		totalCost -= maxA
		fmt.Fprintln(writer, totalCost)
	}
}
```