// @author: the__martian
// 108
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = a; i >= (b); --i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int h, w; cin >> h >> w;
  int mx = 500000;
  vector<vector<int>> v(h, vector<int>(w));
  for (auto &r : v) {
    for (auto &e : r) {
      cin >> e;
      mx = min(e, mx);
    }
  }
  ll res = 0;
  for (auto &r : v) {
    for (auto &e : r) {
      res += e - mx;
    }
  }
  cout << res;
}
	
 #include <bits/stdc++.h>
 
 #define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
 #define all(v) (v).begin(), (v).end()
 using namespace  std;
 #define forn(i,n) for (int i = 0; i < (n); ++i)
 #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
 using ll = long long;
 int mod = (ll)1e9 + 7;
 #define PI acos(-1)
 typedef pair<int, int> pairs;
 
 const int INF = 1e9 + 1;
 const int N = 2e5 + 100;
 const double eps = 1e-7;
 
 template <class T> using V = vector<T>;  
 template <class T> using VV = V<V<T>>;  
 
 template <typename XPAX>
 void ckma(XPAX &x, XPAX y) {
     x = (x < y ? y : x);
 }
 template <typename XPAX>
 void ckmi(XPAX &x, XPAX y) {
     x = (x > y ? y : x);
 }
 
 void solve() {
 
 
 	using D = long double;

 	int n;cin >> n;

 	V<int>a (n);

 	forn(i, n) cin >> a[i];

 	D ans = 0;
 	sort(all(a));
 	D x = a[(n - 1) / 2] * 0.5;

 	ans += n * x;


 	forn(i, n) {
 		ans -= min((D)a[i], x * 2.0);
 	
 		ans += a[i];
 	}
 	ans /= n;
 	cout << FIXED_FLOAT(ans) << '\n';
 
 
 
 }
 void test_case() {
     int t;
     cin >> t;
     forn(p, t) {
 
         //cout << "Case #" << p + 1 << ": ";
         solve();
     }
 }
 int main() {
 
     ios::sync_with_stdio(false);
     cin.tie(0);
 
     solve();
 }
  
