/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T> 
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

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

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)


int x, y;
int main() {
	x = read<int>(), y = read<int>();
	int X = x, Y = y;
	x = (X + Y) / 2;
	y = X - x;
	printf("%d %d\n", x, y);
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  int mn = 1e9;
  rep(i, h) rep(j, w) mn = min(mn, a[i][j]);

  int ans = 0;
  rep(i, h) rep(j, w) ans += a[i][j] - mn;
  cout << ans << endl;
  return 0;
}