#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define irreps(i, m, n) for (long long i = ((long long)(n)-1); i > (long long)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (long long)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b,x,y; cin>>a>>b>>x>>y;
  
  if(a==b){
    cout<<x<<endl;
  }else if(a<b){
    ll ans=x;
    if(2*x<y) ans+=(b-a)*2*x;
    else ans+=(b-a)*y;
    cout<<ans<<endl;
  }else{
    ll ans=x;
    if(2*x<y) ans+=2*x*(a-b-1);
    else ans+=y*(a-b-1);
    cout<<ans<<endl;
  }
  
}

#include<bits/stdc++.h>
//#include<iostream>
//#include<string>
//#include<cmath>
//#include<cstdio>
//#include<cstring>
//#include<algorithm>
//#include<cctype>
//#include<vector>
//#include<map>
//#include<deque>
//#include<queue>
using namespace std;

#define re register
#define inf 0x3f3f3f3f
//#define inf 0x3f3f3f3f3f3f3f3fll
#define ll long long
//#define int ll
//#define x first
//#define y second

typedef pair<int,int> PII;

template<typename T>
inline void read(T &x){
	re char ch=getchar();re bool f=false;x=0;
	while(!isdigit(ch)){if(ch=='-'){f=true;}ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	x=f?-x:x; return ;
}

template<typename T>
inline void write(T x){
	if(x<0){putchar('-');x=-x;}
	if(x>=10){write(x/10);}
	putchar(x%10+'0');
}

double const eps=1e-18;
int const N=3e5+5;
int a[N];
struct SegmentTree{
	int l,r;
	int dat;
}t[N*4];

inline void build(int p,int l,int r){
	t[p].l=l,t[p].r=r;
	if(l==r){
		t[p].dat=a[l];
		return ;
	}
	int mid=(l+r)>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	t[p].dat=t[p<<1].dat^t[p<<1|1].dat;
}

inline void modify(int p,int x,int y){
	if(t[p].l==t[p].r){
		t[p].dat^=y;
		return ;
	}
	int mid=(t[p].l+t[p].r)>>1;
	if(x<=mid) modify(p<<1,x,y);
	if(x>mid) modify(p<<1|1,x,y);
	t[p].dat=t[p<<1].dat^t[p<<1|1].dat;
}

inline int ask(int p,int l,int r){
	if(t[p].l>=l&&t[p].r<=r){
		return t[p].dat;
	}
	int mid=(t[p].l+t[p].r)>>1;
	int ans=0;
	if(l<=mid) ans^=ask(p<<1,l,r);
	if(mid<r) ans^=ask(p<<1|1,l,r);
	return ans;
}

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,m; read(n),read(m);
	for(int i=1;i<=n;i++){
		read(a[i]);
	}
	build(1,1,n);
	while(m--){
		int op,x,y; read(op),read(x),read(y);
		if(op==1){
			modify(1,x,y);
		}
		else{
			write(ask(1,x,y)),puts("");
		}
	}
	return 0;
}
/*
3 4
1 2 3
2 1 3
2 2 3
1 2 3
2 2 3

10 10
0 5 3 4 7 0 0 0 1 0
1 10 7
2 8 9
2 3 6
2 1 6
2 1 10
1 9 4
1 6 1
1 6 3
1 1 7
2 3 5
*/