Residue Principle for Summatory Functions