#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000000000000
ll segtree[400005];
ll lazy[400005];
ll arr[100005];
void build(ll n,ll b,ll e){
if(b>e){
return;
}
if(b==e){
segtree[n]=arr[b];
return;
}
ll mid=(b+e)/2;
build(2*n+1,b,mid);
build(2*n+2,mid+1,e);
segtree[n]=min(segtree[2*n+1],segtree[2*n+2]);
}
void update(ll n,ll b,ll e,ll l,ll r,ll value)
{
if(b>e){
return;
}
if(lazy[n]!=0){
segtree[n]+=lazy[n];
if(b!=e){
lazy[2*n+1]+=lazy[n];
lazy[2*n+2]+=lazy[n];
}
lazy[n]=0;
}
if(b>r||e<l){
return;
}
if(l<=b&&r>=e){
segtree[n]+=value;
if(b!=e)
{
lazy[2*n+1]+=value;
lazy[2*n+2]+=value;
}
return;
}
ll mid=(b+e)/2;
update(2*n+1,b,mid,l,r,value);
update(2*n+2,mid+1,e,l,r,value);
segtree[n]=min(segtree[2*n+1],segtree[2*n+2]);
}
ll query(ll n,ll b,ll e,ll l,ll r){
if(b>e){
return MAX;
}
if(lazy[n]!=0){
segtree[n]+=lazy[n];
if(b!=e){
lazy[2*n+1]+=lazy[n];
lazy[2*n+2]+=lazy[n];
}
lazy[n]=0;
}
if(b>r||e<l){
return MAX;
}
if(l<=b&&r>=e){
return segtree[n];
}
ll mid=(b+e)/2;
return min(query(2*n+1,b,mid,l,r),query(2*n+2,mid+1,e,l,r));
}
int main()
{
ll i,j,n,m,t,a,b,value,q,c;
scanf("%lld",&n);
for(i=1;i<=n;i++){
scanf("%lld",&arr[i]);
}
build(1,1,n);
scanf("%lld",&q);
for(i=0;i<q;i++){
scanf("%lld%lld%lld",&a,&b,&c);
if(a==1){
scanf("%lld",&value);
update(1,1,n,b,c,value);
}
else{
printf("%lld\n",query(1,1,n,b,c));
}
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBNQVggMTAwMDAwMDAwMDAwMDAwMDAwMAoKbGwgc2VndHJlZVs0MDAwMDVdOwpsbCBsYXp5WzQwMDAwNV07CmxsIGFyclsxMDAwMDVdOwoKdm9pZCBidWlsZChsbCBuLGxsIGIsbGwgZSl7CiAgICBpZihiPmUpewogICAgICAgIHJldHVybjsKICAgIH0KCiAgICBpZihiPT1lKXsKICAgICAgICBzZWd0cmVlW25dPWFycltiXTsKICAgICAgICByZXR1cm47CiAgICB9CgogICAgbGwgbWlkPShiK2UpLzI7CiAgICBidWlsZCgyKm4rMSxiLG1pZCk7CiAgICBidWlsZCgyKm4rMixtaWQrMSxlKTsKCiAgICBzZWd0cmVlW25dPW1pbihzZWd0cmVlWzIqbisxXSxzZWd0cmVlWzIqbisyXSk7Cn0KCnZvaWQgdXBkYXRlKGxsIG4sbGwgYixsbCBlLGxsIGwsbGwgcixsbCB2YWx1ZSkKewoKICAgIGlmKGI+ZSl7CiAgICAgICAgcmV0dXJuOwogICAgfQoKICAgIGlmKGxhenlbbl0hPTApewogICAgICAgIHNlZ3RyZWVbbl0rPWxhenlbbl07CiAgICAgICAgICAgIGlmKGIhPWUpewogICAgICAgICAgICBsYXp5WzIqbisxXSs9bGF6eVtuXTsKICAgICAgICAgICAgbGF6eVsyKm4rMl0rPWxhenlbbl07CiAgICAgICAgICAgIH0KICAgICAgICBsYXp5W25dPTA7CiAgICB9CgogICAgaWYoYj5yfHxlPGwpewogICAgICAgIHJldHVybjsKICAgIH0KCiAgICBpZihsPD1iJiZyPj1lKXsKICAgICAgICBzZWd0cmVlW25dKz12YWx1ZTsKICAgICAgICAgICAgaWYoYiE9ZSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgbGF6eVsyKm4rMV0rPXZhbHVlOwogICAgICAgICAgICAgICAgbGF6eVsyKm4rMl0rPXZhbHVlOwogICAgICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgfQoKICAgIGxsIG1pZD0oYitlKS8yOwogICAgdXBkYXR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wogICAgICAgICAgICBpZihhPT0xKXsKICAgICAgICAgICAgICAgIHNjYW5mKCIlbGxkIiwmdmFsdWUpOwogICAgICAgICAgICAgICAgdXBkYXRlKDEsMSxuLGIsYyx2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZXsKICAgICAgICAgICAgICAgIHByaW50ZigiJWxsZFxuIixxdWVyeSgxLDEsbixiLGMpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KfQo=