#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ford(i,a,b) for(int i=a;i<=b;i++)
#define foru(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,a,b) for(int i=a;i<b;i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define bug(x) cout<<x<<'\n';
#define bit(x,i) ((x>>i)&1ll)

int n,x,kq=0;

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

    cin>>n;

    ford(i,1,n){
        cin>>x;
        if(x>10) kq+=(x-10);
    }

    cout<<kq;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> A(n);
  map<int, int> cnt;
  rep(i, n) {
    cin >> A[i];
    cnt[A[i]]++;
  }
  int mn = k;
  ll ans = 0;
  rep(i, n) {
    ans += 1LL * (mn - min(mn, cnt[i])) * i;
    chmin(mn, cnt[i]);
  }
  ans += mn * n;
  cout << ans << endk;
  return 0;
}
