Elementary divisors of derivations