#include <cstdio>
#include <algorithm>
using namespace std;
int tree[200005];
int v[100005];
void m_build(int root ,int left,int right){
if(left==right)
tree[root]=v[left];
else{
int mid=(left+right)/2;
m_build(root*2+1, left, mid);
m_build(root*2+2, mid+1, right);
tree[root]=min(tree[root*2+1],tree[root*2+2]);
}
}
int m_find(int root,int f_l,int f_r,int left,int right){
if(f_r<left||f_l>right)
return 0xfffffff;
if(f_l<=left&&f_r>=right)
return tree[root];
int mid=(left+right)/2;
return min(m_find(root*2+1,f_l,f_r,left,mid),m_find(root*2+2, f_l, f_r,mid+1 , right));
}
void m_updata(int root,int value,int pos,int left,int right){
if(left==right){
if(left==pos)
tree[root]=value;
return;
}
int mid=(left+right)/2;
if(pos<=mid)
m_updata(root*2+1, value, pos, left, mid);
else
m_updata(root*2+2, value, pos, mid+1,right);
tree[root]=min(tree[root*2+1],tree[root*2+2]);
}
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&v[i]);
m_build(0, 1, n);
int q,pos,value;
int f_l,f_r;
scanf("%d",&q);
while (q--) {
scanf("%d%d",&pos,&value);
m_updata(0, value, pos, 1, n);
scanf("%d%d",&f_l,&f_r);
printf("%d\n",m_find(0, f_l, f_r, 1, n));
}
return 0;
}