```go
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
if !scanner.Scan() {
return
}
pVal, _ := strconv.Atoi(scanner.Text())
p := int64(pVal)
a := make([]int64, n)
var totalSum int64
for i := 0; i < n; i++ {
scanner.Scan()
val, _ := strconv.ParseInt(scanner.Text(), 10, 64)
a[i] = val
totalSum += val
}
var maxScore int64 = 0
var currentSum int64 = 0
// We iterate through all possible split points.
// A split point i means the first part is a[0]...a[i]
// and the second part is a[i+1]...a[n-1].
// i ranges from 0 to n-2 to ensure both parts have at least one element.
for i := 0; i < n-1; i++ {
currentSum += a[i]
part1Score := currentSum % p
part2Score := (totalSum - currentSum) % p
totalScore := part1Score + part2Score
if totalScore > maxScore {
maxScore = totalScore
}
}
fmt.Println(maxScore)
}
```