For problem statement at 0-999/800-899/830-839/839/problemD.txt this is a correct solution, but verifier at 0-999/800-899/830-839/839/verifierD.go ends with All tests passed can you fix the verifier? package main
import (
"bufio"
"io"
"os"
"strconv"
)
const MOD int64 = 1000000007
const MAXV = 1000000
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
readInt := func() int {
for idx < len(data) && (data[idx] < '0' || data[idx] > '9') {
idx++
}
num := 0
for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
num = num*10 + int(data[idx]-'0')
idx++
}
return num
}
n := readInt()
freq := make([]int, MAXV+1)
maxA := 0
for i := 0; i < n; i++ {
x := readInt()
freq[x]++
if x > maxA {
maxA = x
}
}
pow2 := make([]int64, n+1)
pow2[0] = 1
for i := 1; i <= n; i++ {
pow2[i] = (pow2[i-1] * 2) % MOD
}
exact := make([]int64, maxA+1)
var ans int64
for d := maxA; d >= 2; d-- {
c := 0
var sub int64
for mult := d; mult <= maxA; mult += d {
c += freq[mult]
if mult != d {
sub += exact[mult]
if sub >= MOD {
sub -= MOD
}
}
}
if c == 0 {
continue
}
val := int64(c)*pow2[c-1]%MOD - sub
if val < 0 {
val += MOD
}
exact[d] = val
ans += int64(d) * val % MOD
if ans >= MOD {
ans -= MOD
}
}
w := bufio.NewWriter(os.Stdout)
w.WriteString(strconv.FormatInt(ans, 10))
w.WriteByte('\n')
w.Flush()
}