Optimising Funny Marbles
Given the constraints, the maximum sum, N * max(A), would be 2000000000, which fits within a Java int.  You don't need a long.

Your code is a straightforward implementation of the challenge; there's nothing to micro-optimize.  Your only hope is to use a different approach.

Assuming that the test is heavy on "S" queries, you would be better off keeping an array of cumulative sums.  Then you could answer an "S" query in constant time.

What to do with "G" and "T" operations, though?  The elegant approach would be to update the entire cumulative sums array for each "G" or "T".  However, since N is likely to be larger than Q, you might get better performance keeping the "G" and "T" operations as a list of exceptions instead.