code: public void push(long x) {
      if (this.queueSize == this.maxSize) {
        assert this.last == this.first;
        this.sumOfQueue -= this.elems.get(this.last);
        if ((++this.last) == this.maxSize)
          this.last = 0;
      } else
        this.queueSize++;
      this.sumOfQueue += x;
      this.elems.set(this.first, x);
      if ((++this.first) == this.maxSize) {
        this.first = 0;
        this.last = 0;
      }
    }
docs: Pushes a new element to the queue.
  @param x the new element