Question 7
John and Carlson alternately take $1,2,3,4,\ldots$ candies from a bag. When too few remain for the next full turn, the boy whose turn it is takes all the rest. John receives $1012$ candies in total. How many candies were initially in the bag?