Fix a nonnegative integer a0 to define a sequence of integers a0,a1,… by letting ak,k≥1 be the smallest integer (strictly) greater than ak−1 making ak−1+ak into a perfect square. Let S be the set of positive integers not expressible as the difference of two terms of the sequence (ak)k≥0. Prove that S is finite and determine its size in terms of a0.