Rearrange values to prevent integer overflow