```
class NumArray {
int nums[];
public NumArray(int[] nums) {
this.nums = nums;
}
public void update(int i, int val) {
nums[i]=val;
}
public int sumRange(int i, int j) {
int sum = 0;
int p=i;
while(p<=j){
if(p!=j){
sum+=nums[p++];
sum+=nums[j--];
}else sum+=nums[p++];
}
return sum;
}
}
```