Read G.H. Hardy's Introduction to Number Theory, Then possibly A Course of Pure Mathematics, also by him.
Note that the level for which you're aiming, is a level wherein such summation is much closer to triviality, than it is to `black magic` - whatever that means.