#include<stdio.h>
#include<string.h>
#define min(a,b)(a)<(b)?(a):(b)
#define  MAX_N (1<<20)
int N,num[MAX_N],tree[2*MAX_N-1];
int init(int f,int t)
{
	int i;
	for(N=1;N<=t-f+1;N*=2);
	for(i=0;f+i<=t;++i)
		tree[i+N]=num[f+i];
	for(;i<N;i++)
		tree[i+N]=1000000005;
	for(i=N-1;i>=0;--i)
		tree[i]=min(tree[i*2],tree[i*2+1]);
	return tree[1];
}

int main()
{
	int n,i,t,q,x,y,z;
	scanf("%d%d",&n,&q);
	for(i=0;i<n;i++)
		scanf("%d",&num[i]);
	for(;q--;)
	{
		scanf("%d%d%d",&x,&y,&z);
		switch(x)
		{
		case 0:t=num[z];memmove(num+y+1,num+y,(z-y)*4);num[y]=t;break;
		case 1:;printf("%d\n",init(y,z));break;
		case 2:num[y]=z;break;
		}
	}
	return 0;
}