//
// main.cpp
// uva 12086 - Potentiometers--树状数组
//
// Created by XD on 15/9/10.
// Copyright (c) 2015年 XD. All rights reserved.
//
/*
树状树组,
*/
#include <iostream>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<vector>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
#define ll long long
using namespace std ;
const int maxn = 200000+ 10 ;
ll c[maxn] ;
ll arr[maxn] ;
int lowerbit(int x)
{
return x &(-x) ;
}
void updata(int x , ll v )
{
ll temp = v ;
v = v - arr[x] ;
arr[x] = temp ;
while (x <=maxn) {
c[x] += v ; x += lowerbit(x) ;
}
}
ll sum(int x)
{
ll ret = 0 ;
while (x > 0) {
ret += c[x] ; x-=lowerbit(x) ;
}
return ret ;
}
int main(int argc, const char * argv[]) {
int n,d,x,y;
char cmd[10] ;
int kase = 0 ;
while (scanf("%d" , &n) , n) {
memset(arr, 0, sizeof(arr)) ;
memset(c, 0, sizeof(c)) ;
if (kase) {
printf("\n") ;
}
for (int i = 1; i <= n ; i++) {
scanf("%d" , &d) ;
updata(i, d) ;
}
printf("Case %d:\n" ,++kase) ;
while (scanf("%s" ,cmd)&&cmd[0]!='E') {
scanf("%d%d" ,&x,&y) ;
if (cmd[0] == 'M') {
printf("%lld\n" , sum(y) - sum(x-1)) ;
}
else{
updata(x, y) ;
}
}
}
return 0;
}