```go
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func main() {
// Configure fast I/O
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
// Increase buffer size to handle potential large inputs, although ScanWords mitigates this
const maxCapacity = 2048 * 1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
if !scanner.Scan() {
return
}
nVal, _ := strconv.Atoi(scanner.Text())
if !scanner.Scan() {
return
}
mVal, _ := strconv.ParseInt(scanner.Text(), 10, 64)
a := make([]int64, nVal)
for i := 0; i < nVal; i++ {
scanner.Scan()
val, _ := strconv.ParseInt(scanner.Text(), 10, 64)
a[i] = val
}
if nVal == 0 {
fmt.Println(0)
return
}
// Compute differences between consecutive elements in circular manner
d := make([]int64, nVal)
for i := 0; i < nVal-1; i++ {
d[i] = a[i+1] - a[i]
}
d[nVal-1] = mVal + a[0] - a[nVal-1]
// Compute the difference array for the reflected set
// db corresponds to differences of {k-x | x in A} sorted
db := make([]int64, nVal)
for i := 0; i < nVal-1; i++ {
db[i] = d[nVal-2-i]
}
db[nVal-1] = d[nVal-1]
// KMP Preprocessing on db
pi := make([]int, nVal)
for i := 1; i < nVal; i++ {
j := pi[i-1]
for j > 0 && db[i] != db[j] {
j = pi[j-1]
}
if db[i] == db[j] {
j++
}
pi[i] = j
}
// KMP Search in d concatenated with itself (circular search)
// We search for occurrences of db in d+d
var solutions []int64
j := 0
// Effectively iterating over D cyclically
for i := 0; i < 2*nVal-1; i++ {
val := d[i%nVal]
for j > 0 && val != db[j] {
j = pi[j-1]
}
if val == db[j] {
j++
}
if j == nVal {
// Match found
shift := i - nVal + 1
// Determine k corresponding to this symmetry
// The match aligns D[shift] with DB[0]
// DB[0] corresponds to edge (k - A[N-1]) -> (k - A[N-2])
// D[shift] corresponds to edge A[shift] -> A[shift+1]
// Thus A[shift] = k - A[N-1]
k := a[shift] + a[nVal-1]
if k >= mVal {
k -= mVal
}
solutions = append(solutions, k)
j = pi[nVal-1]
}
}
// Sort solutions and remove duplicates
sort.Slice(solutions, func(i, j int) bool { return solutions[i] < solutions[j] })
unique := make([]int64, 0, len(solutions))
if len(solutions) > 0 {
unique = append(unique, solutions[0])
for i := 1; i < len(solutions); i++ {
if solutions[i] != solutions[i-1] {
unique = append(unique, solutions[i])
}
}
}
// Output results
fmt.Println(len(unique))
if len(unique) > 0 {
writer := bufio.NewWriter(os.Stdout)
for i, v := range unique {
if i > 0 {
writer.WriteByte(' ')
}
writer.WriteString(strconv.FormatInt(v, 10))
}
writer.WriteByte('\n')
writer.Flush()
}
}
```