How to reduce amount of array values in each iteration in array modifier? How to reduce amount  of array values in each iteration in array modifier?

what I mean:

let's say we have a cube with two array modifiers which gives us an array 5x5

what I need:

next array row on Z axis (3x3) right above previous,  and next (1x1). Is it possible to do with modifiers or drivers? How?
One way to do this is using the particle system set to Grid distribution :

 


make a pyramid ( default cube with the top face resized )





add a particle system to this pyramid :





change the particle size / grid resolution /pyramid mesh  to get the desired results
in the modifiers tab of the pyramid convert the particles to a real mesh :