#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>
#include <stack>
#include <deque>
#include <iomanip>
#include <set>
#include <map>
#include <cassert>
#include <ctime>
#include <list>
#include <iomanip>
using namespace std;
string file = "maxq";
ifstream cin( (file + ".in").c_str() );
ofstream cout( (file + ".out").c_str() );
const int MAXN = 200005;
const int oo = 0x3f3f3f3f;
typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;
const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; }
const inline void Get_min(int &a, const int b) { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b) { if( a < b ) a = b; }
struct node {
int sum;
int pref;
int suf;
int best;
node() {
Update(-oo);
}
void Update(const int &Value) {
sum = Value;
pref = Value;
suf = Value;
best = Value;
}
void Update(const node &left, const node &right) {
sum = left.sum + right.sum;
pref = max(left.pref, left.sum + right.pref);
suf = max(right.suf, right.sum + left.suf);
best = max(left.best, right.best);
best = max(best, left.suf + right.pref);
}
};
node A[MAXN*4];
int N, M;
inline void Update(int Node, int st, int dr, int pos, int val) {
if(st == dr) {
A[Node].Update(val);
return;
}
int mid = ((st + dr)/2);
if(pos <= mid)
Update(2*Node, st, mid, pos, val);
else
Update(2*Node + 1, mid+1, dr, pos, val);
A[Node].Update(A[2*Node], A[2*Node+1]);
}
inline node Query(int Node, int st, int dr, int a, int b) {
if(a <= st && dr <= b)
return A[Node];
int mid = ((st + dr) / 2);
node left, right;
if(a <= mid)
left = Query(2*Node, st, mid, a, b);
if(mid < b)
right = Query(2*Node + 1, mid + 1, dr, a, b);
node ret;
ret.Update(left, right);
return ret;
}
int main() {
cin >> N;
for(int i = 1 ; i <= N ; ++ i) {
int x;
cin >> x;
Update(1, 1, N, i, x);
}
cin >> M;
for(int i = 1 ; i <= M ; ++ i) {
bool op;
int x, y;
///0 i p
///1 a b
cin >> op >> x >> y;
if(!op) {
++ x;
Update(1, 1, N, x, y);
}
else {
++ x, ++ y;
cout << Query(1, 1, N, x, y).best << '\n';
}
}
cin.close();
cout.close();
return 0;
}