Problem 1 - use sum of sequences to make it run in O(1)