An inverse problem for a class of lacunary canonical systems with diagonal Hamiltonian