Put everything together
Optimize multiplication by constant