using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("8 4");
WillReturn.Add("1 3 16");
WillReturn.Add("1 6 24");
WillReturn.Add("2 4 8");
WillReturn.Add("2 1 7");
//24
//40
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
SplitAct(InputList[0]);
int N = wkArr[0];
var Ins_Fenwick_Tree = new Fenwick_Tree(N + 1);
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
long T = wkArr[0];
if (T == 1) {
long Pos = wkArr[1];
long X = wkArr[2];
long CurrVal = Ins_Fenwick_Tree.GetSum(Pos, Pos, true);
Ins_Fenwick_Tree.Add(Pos, -CurrVal + X, true);
}
if (T == 2) {
long L = wkArr[1];
long R = wkArr[2];
long CurrVal = Ins_Fenwick_Tree.GetSum(L, R - 1, true);
Console.WriteLine(CurrVal);
}
}
}
}
#region Fenwick_Tree
// フェニック木
internal class Fenwick_Tree
{
private long[] mBitArr;
private long mN;
// コンストラクタ
internal Fenwick_Tree(long pItemCnt)
{
mN = pItemCnt;
mBitArr = new long[pItemCnt + 1];
}
// [pSta,pEnd] のSumを返す
internal long GetSum(long pSta, long pEnd, bool pIsZeroOrigin)
{
return GetSum(pEnd, pIsZeroOrigin) - GetSum(pSta - 1, pIsZeroOrigin);
}
// [0,pEnd] のSumを返す
internal long GetSum(long pEnd, bool pIsZeroOrigin)
{
if (pIsZeroOrigin) {
pEnd++; // 1オリジンに変更
}
long Sum = 0;
while (pEnd >= 1) {
Sum += mBitArr[pEnd];
pEnd -= pEnd & -pEnd;
}
return Sum;
}
// [I] に Xを加算
internal void Add(long pI, long pX, bool pIsZeroOrigin)
{
if (pIsZeroOrigin) {
pI++; // 1オリジンに変更
}
while (pI <= mN) {
mBitArr[pI] += pX;
pI += pI & -pI;
}
}
}
#endregion