Matsubara sum and complex analysis

Let $\omega_n=e^{\mathrm{i} \pi (2n+1)/N}$, for n=0,...,N-1, be the N-th roots of (-1). So that the sum for a suitable analytic functions $f(z)$ can be turned into a contour integral

$$S=\frac{1}{N} \sum_{n=0}^{N-1} f(\omega_n)=\frac{1}{2\pi \mathrm{i}} \oint_C \frac{\mathrm{d}z}{z} \frac{z^N}{z^N+1} f(z),$$

where C consists of a pair of oppositely oriented concentric circles. The annulus formed by the circles should include all the roots of (-1), but exclude all singularities of $f$. Now how to use this result to show that, for N even,

$$S=\frac1{N} \sum_{n=0}^{N-1} \frac{\sinh E}{\sinh^2 E+\sin^2 \frac{(2n+1)\pi}{N}}=\frac1{\cosh E} \tanh \frac{NE}{2}$$

And also how to show that if we take $N\to\infty$ while scaling $E\to 0$ in some suitable manner, the above equation turns into

$$\sum_{-\infty}^{\infty} \frac{a}{a^2+[(2n+1)\pi]^2}=\frac12\tanh\frac{a}{2}$$

-

here is a hint (as it is a homework): you should take (I'm not revealing anything :) $$f=\frac{\sinh E}{\sinh^2 E +((z-z^{-1})/2i)^2}.$$ The sum of all the residues of $f(z)\frac{z^N}{z^N+1}\frac{dz}{z}$ (including the residue at $\infty$) is $0$, while $S$ is the sum over the residues at the roots of $z^N+1$. Hence $S$ is also minus the sum over the remaining residues. So you just need to find them (don't forget about the residue at $\infty$ - in this case it seems to be $0$, but you need to verify it).
for the second question - just set $E=a/N$ (for a fixed $a$) and take the limit $N\to\infty$.