Minimum energy for linear systems with finite horizon: a non-standard Riccati equation