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

void readFile(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    readFile();
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, x;
    cin >> n >> x;
    vector<ll> ans;
    for(ll i = 0 ; i < n ; ++i){
        ll val;
        cin >> val;
        if(val != x) ans.push_back(val);
    }
    for(ll i : ans) cout << i << ' ';
    cout << '\n';
}
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	int h,w;
	std::cin >> h >> w;
	int n=h*w;
	V<int> a(n);
	fill(a);
	int min=a[0];
	rep(i,n) min=std::min(min,a[i]);
	lnt ans=0;
	rep(i,n) ans+=a[i]-min;
	print(ans);
}
