Exact time-dependent invariants for n -dimensional systems