Kudos to @GuillaumeOutters for bringing up rounding errors.
It seems that different orderings of summing results in (exactly?) two different results, but the difference is something like 17395708 vs 17395696 -- that's a difference of 12, and already way outside the significant digits of the real
type. I shouldn't even have considered this difference as significant.
I confirmed this by casting the values to double precision
before summing, and the problem went away.
Even though it feels strange that the result switches between these exact two values (for one group; the other groups have different values but with similar characteristics), that's likely just up to how the real
type behaves.
Thanks to everybody who chimed in (in the comments to the question).