Interconnected mechanical systems, part I: geometry of interconnection and implicit Hamiltonian systems