sum(begin: number, end: number): number {
    invariant(begin <= end, 'Begin must precede end');
    return this.sumUntil(end) - this.sumUntil(begin);
  }
Returns the sum get(begin) + get(begin + 1) + ... + get(end - 1).