I would recommend Drivers for this.
It really depends on what you are doing, but if turns into anything related to animation, this seems logical.
The disclaimer is that it won't work with the array modifier, however duplication via something like Ctrl+D also copies the driver so that part stays dynamic.
First steps are to create both a cube and an empty at the 0,0,0 origin.
To create the driver, 1st select the Cube Object, then turn on your properties panel N, and Right-Click on the X rotation field >> Then Add Single Driver.
Go to the Graph Editor Screen, and at the bottom menu change F-Curve to Drivers.
N to bring up the right side panel if it's not up already.
At the left side of the Graph Editor, be sure to select the X Euler Rotation Entry.
Scroll down to the bottom of the panel on your right and there should be a variable called var already, make sure that its type is set to distance, I believe that by default it gets set to Transform Channel.
Then set Ob/Bone 1: Empty
Then set Ob/Bone 2: Cube
Up above the variable list is an Expression field labeled Expr:, go ahead and set this field to the following:
And hit enter.
You can now close the graph editor, and keyframe &/OR duplicate the cube around, and it will rotate respective to its distance from the Empty's location.