OK,
I think I noticed a glitch in the interface that briefly displayed a -1 in the value field.
That got me thinking: probably After Effects is doing an error check before it tries to render the image or something. Or it is trying to execute/check the code at some other edge cases that make it fail the code, but wouldn’t fail when we need it at display/rendertime
Indeed, explicitly setting total=3 works, setting a=b=c=[1,1,1,1]; works too, so at the time it is checking for the errors, it is not correctly sampling the images.
using x=Math.max(0,total-1); works
(if you change the first value of the array back to an integer)
So all this means total is equal to zero while error-checking, but not while rendering the frame.
Which is indeed strange that it doens’t occur on text-layers.