On the Maslov index of symplectic paths that are not transversal to the Maslov cycle. Semi-Riemannian index theorems in the degenerate case