  We consider a {\em Hamiltonian setup} $\sextuple$, where $(\mathcal
M,\omega)$ is a symplectic manifold, $\mathfrak L$ is a distribution of
Lagrangian subspaces in $\mathcal M$, $\mathcal P$ a Lagrangian submanifold of
$ \mathcal M$, $H$ is a smooth time dependent Hamiltonian function on $\mathcal
M$ and $\Gamma:[a,b]\to\mathcal M$ is an integral curve of the Hamiltonian flow
$\Hf$ starting at $\mathcal P$. We do not require any convexity property of the
Hamiltonian function $H$. Under the assumption that $\Gamma(b)$ is not
$\mathcal P$-focal it is introduced the Maslov index $\maslov(\Gamma)$ of
$\Gamma$ given in terms of the first relative homology group of the Lagrangian
Grassmannian; under generic circumstances $\maslov(\Gamma)$ is computed as a
sort of {\em algebraic count} of the $\mathcal P$-focal points along $\Gamma$.
We prove the following version of the Index Theorem: under suitable hypotheses,
the Morse index of the Lagrangian action functional restricted to suitable
variations of $\Gamma$ is equal to the sum of $\maslov(\Gamma)$ and a {\em
convexity term} of the Hamiltonian $H$ relative to the submanifold $\mathcal
P$. When the result is applied to the case of the cotangent bundle $\mathcal
M=TM^*$ of a semi-Riemannian manifold $(M,g)$ and to the geodesic Hamiltonian
$H(q,p)=\frac12 g^{-1}(p,p)$, we obtain a semi-Riemannian version of the
celebrated Morse Index Theorem for geodesics with variable endpoints in
Riemannian geometry.
