I have a queue $Q$ where elements can be popped from the left and added to the right in $O(1)$ time. The elements are members of a fixed semigroup $S$ with $O(1)$ time multiplication. Let the current state of the $Q$ be the sequence $(s_1,\ldots,s_n)$. I am interested in the product
$$\prod Q = s_1 \cdots s_n.$$
Question: Is it possible to maintain this product in amortized constant time as elements are added and removed?