//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define Dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int H, W;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> H >> W;
    int SUM = 0, MIN = INF;
    for (int i = 0; i < H * W; i++) {
        int x;
        cin >> x;
        chmin(MIN, x);
        SUM += x;
    }
    cout << SUM - MIN * H * W << endl;

    solve();
    return 0;
}

// Problem: F - Range Xor Query
// Contest: AtCoder - AtCoder Beginner Contest 185
// URL: https://atcoder.jp/contests/abc185/tasks/abc185_f
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// 
// Author: masked_huh
// Created: 13/12/2020 18:24

/*Success isn't permanent, failure isn't fatal,
it's the courage to continue that counts.*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
typedef long long ll;
#define F first
#define S second
#define vi vector<int> 
#define vc vector<char>
 
const ll mod=1e9+7;

const int N=300001;
int arr[N];
int tree[4*N];

void build(int node,int start,int end)
{
    if(start==end)
    {
        tree[node]=arr[start];
        return;
    }

    int mid=(start+end)/2;

    build(2*node,start,mid);
    build(2*node+1,mid+1,end);

    tree[node]=tree[2*node]^tree[2*node+1];

    return;
}

void update(int node,int start,int end,int idx,int val)
{
    if(start==end)
    {
        arr[idx]^=val;
        tree[node]^=val;
        return;
    }

    int mid=(start+end)/2;

    if(start<=idx && idx<=mid)
        update(2*node,start,mid,idx,val);
    else
        update(2*node+1,mid+1,end,idx,val);

    tree[node]=tree[2*node]^tree[2*node+1];

    return;
} 

int query(int node,int start,int end,int l, int r)
{
    if(start>r||end<l)
        return 0;
    if(start>=l&&end<=r)
        return tree[node];

    int mid=(start+end)/2;

    int val1=query(2*node,start,mid,l,r);
    int val2=query(2*node+1,mid+1,end,l,r);

    return (val1^val2);
}

void solve()
{
    int n,q;
    sfi(n)
    sfi(q)
    
    f(i,1,n+1)
    	sfi(arr[i])
    
    build(1,1,n);
    
    while(q--)
    {
    	int t,x,y;
    	sfi(t)
    	sfi(x)
    	sfi(y)
    	if(t==1)
    	{
    		update(1,1,n,x,y);
    	}
    	else
    	{
    		int ans=query(1,1,n,x,y);
    		
    		pfin(ans)
    	}
    }
    
    return;
}

int main()
{
	solve();

	return 0;
}