package main
import (
"io"
"os"
)
const MOD int64 = 998244353
type Group struct {
lim int
cnt int
sum int64
}
type FastScanner struct {
data []byte
idx int
}
func (fs *FastScanner) NextInt() int {
n := len(fs.data)
for fs.idx < n && (fs.data[fs.idx] < '0' || fs.data[fs.idx] > '9') {
fs.idx++
}
val := 0
for fs.idx < n {
c := fs.data[fs.idx]
if c < '0' || c > '9' {
break
}
val = val*10 + int(c-'0')
fs.idx++
}
return val
}
func appendInt(dst []byte, x int64) []byte {
if x == 0 {
dst = append(dst, '0', '\n')
return dst
}
var buf [20]byte
i := len(buf)
for x > 0 {
i--
buf[i] = byte('0' + x%10)
x /= 10
}
dst = append(dst, buf[i:]...)
dst = append(dst, '\n')
return dst
}
func main() {
data, _ := io.ReadAll(os.Stdin)
fs := FastScanner{data: data}
t := fs.NextInt()
out := make([]byte, 0, t*12)
for ; t > 0; t-- {
n := fs.NextInt()
a := make([]int, n)
for i := 0; i < n; i++ {
a[i] = fs.NextInt()
}
groups := make([]Group, 0, 1000)
nextGroups := make([]Group, 0, 1000)
var ans int64
for i := n - 1; i >= 0; i-- {
x := a[i]
nextGroups = nextGroups[:0]
nextGroups = append(nextGroups, Group{lim: x, cnt: 1, sum: 0})
var total int64
for j := 0; j < len(groups); j++ {
g := groups[j]
k := (x-1)/g.lim + 1
lim := x / k
inc := (int64(g.cnt) * int64(k-1)) % MOD
s := g.sum + inc
if s >= MOD {
s -= MOD
}
total += s
if total >= MOD {
total -= MOD
}
last := len(nextGroups) - 1
if nextGroups[last].lim == lim {
nextGroups[last].cnt += g.cnt
ns := nextGroups[last].sum + s
if ns >= MOD {
ns -= MOD
}
nextGroups[last].sum = ns
} else {
nextGroups = append(nextGroups, Group{lim: lim, cnt: g.cnt, sum: s})
}
}
ans += total
if ans >= MOD {
ans -= MOD
}
groups, nextGroups = nextGroups, groups
}
out = appendInt(out, ans)
}
_, _ = os.Stdout.Write(out)
}