#include using namespace std; typedef long long int ll; int n, ans; int a[100]; int b[100]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { int t; cin >> t; a[t]++; } vector v,vv; for (int i = 1; i <= n; i++) { if (a[i] == 0) v.push_back(i); else if (a[i] > 1) { for (int k = 1; k < a[i]; k++) vv.push_back(i); } } for (int i = 0; i < v.size(); i++) { ans += (v[i] - vv[i]); } cout << ans << endl; return 0; }