PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000025. Tổng đoạn có cập nhật (Range Sum Query - Mutable)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

3 lộ trình

Tổng đoạn có cập nhật (Range Sum Query - Mutable)

Range Sum Query - Mutable

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

You are given an array aa of nn integers. Process qq operations in their given order. U i x sets the element at index ii to xx. S l r asks for the current sum al+al+1+⋯+ara_l+a_{l+1}+\cdots+a_r. Array indices are zero-based.

Input

The first line contains n,qn,q. The next line contains nn integers aia_i. Each of the following qq lines has the form U i x or S l r.

Output

For every S operation, print the current inclusive range sum on a separate line.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; 0≤q≤200\le q\le 20; −100≤ai,x≤100-100\le a_i,x\le100; 0≤i<n0\le i<n; 0≤l≤r<n0\le l\le r<n.
  • Subtask 2 (30 points): 1≤n≤7001\le n\le 700; 0≤q≤7000\le q\le 700; −100≤ai,x≤100-100\le a_i,x\le100; 0≤i<n0\le i<n; 0≤l≤r<n0\le l\le r<n.
  • Subtask 3 (50 points): 1≤n≤300001\le n\le 30000; 0≤q≤300000\le q\le 30000; −100≤ai,x≤100-100\le a_i,x\le100; 0≤i<n0\le i<n; 0≤l≤r<n0\le l\le r<n.

Examples

Input

3 3
1 3 5
S 0 2
U 1 2
S 0 2

Output

9
8

Explanation

The original sum is 9. After updating index 1 to 2, the sum becomes 8.