You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N).
Your objective is to remove some of the elements in a so that a will be a good sequence.
Here, an sequence b is a good sequence when the following condition holds true:
 - For each element x in b, the value x occurs exactly x times in b.
For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.
Find the minimum number of elements that needs to be removed so that a will be a good sequence.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - a_i is an integer.
 - 1 \leq a_i \leq 10^9

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N

-----Output-----
Print the minimum number of elements that needs to be removed so that a will be a good sequence.

-----Sample Input-----
4
3 3 3 3

-----Sample Output-----
1

We can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.
[{"code": "import collections\n\nN=int(input())\nL=list(map(int,input().split()))\nL=sorted(L)\nC=collections.Counter(L)\nD=list(C.keys())\nE=list(C.values())\nK=len(C)\nans=0\nfor i in range(K):\n\tif D[i]==E[i]:\n\t\tans+=0\n\tif D[i]>E[i]:\n\t\tans+=E[i]\n\tif D[i]<E[i]:\n\t\tans+=(E[i]-D[i])\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nans = 0\n\nfrom collections import defaultdict\ndd = defaultdict(int)\nfor key in a:\n    dd[key] += 1\nfor key in dd.keys():\n    #print(key,dd[key])\n    if dd[key]>=key:\n        ans += dd[key]-key\n    else:\n        ans += dd[key]\nprint(ans)", "passed": true, "time": 0.24, "memory": 14264.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\ndict={}\nfor i in range(n):\n  if a[i] not in dict:\n    dict[a[i]]=1\n  else:\n    dict[a[i]]+=1\nans=0\nfor i in dict:\n  if dict[i]<i:\n    ans+=dict[i]\n  elif dict[i]==i:\n    continue\n  else:\n    ans+=dict[i]-i\nprint(ans)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    inlis = list(map(int, input().split()))\n    adic = dict()\n    ans = 0\n\n    for i in range(n):\n        a = inlis[i]\n        if a not in adic:\n            adic[a] = 1\n        else:\n            adic[a] += 1\n        if adic[a] > a:\n            ans += 1\n    \n    for num in adic:\n        if adic[num] < num:\n            ans += adic[num]\n\n    print(ans)\n            \n\n        \n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.33, "memory": 14244.0, "status": "done"}, {"code": "n=int(input());a=list(map(int,input().split()));d={}\nfor i in a:\n  if i not in d: d[i]=1\n  else: d[i]+=1\nprint(sum([j if i>j else j-i for i,j in d.items()]))", "passed": true, "time": 0.16, "memory": 14300.0, "status": "done"}, {"code": "from collections import Counter\n\nN = int(input())\nA = Counter(list(map(int, input().split())))\n\nres = 0\nfor values, counts in list(A.items()):\n    if(values > counts):\n        res += counts\n    elif(values < counts):\n        res += counts - values\nprint(res)\n", "passed": true, "time": 0.24, "memory": 14072.0, "status": "done"}, {"code": "N=int(input())\n*A,=map(int,input().split())\nimport collections\n\nc = collections.Counter(A)\n\nans=0\nfor k,v in c.items():\n    if k == v: continue\n    if k < v: # k\u306b\u5bfe\u3057\u3066\u8981\u7d20\u6570\u304c\u591a\u3044\u306e\u3067\u53d6\u308a\u9664\u304f\n        ans+=v-k\n    if v < k: # k\u306b\u5bfe\u3057\u3066\u8981\u7d20\u6570\u304c\u5c11\u306a\u3044\u306e\u3067\u3001\u3059\u3079\u3066\u53d6\u308a\u9664\u304f\n        ans+=v\nprint(ans)", "passed": true, "time": 0.24, "memory": 14164.0, "status": "done"}, {"code": "input();a=list(map(int,input().split()));d={}\nfor i in a:\n  if i not in d: d[i]=1\n  else: d[i]+=1\nprint(sum([j if i>j else j-i for i,j in d.items()]))", "passed": true, "time": 0.17, "memory": 14204.0, "status": "done"}, {"code": "from collections import defaultdict\nN = int(input())\nA = list(map(int,input().split()))\nhashmap = defaultdict(int)\nfor a in A:\n  hashmap[a]+=1\nans = 0\nfor k, v in hashmap.items():\n  if k < v:\n    ans+=v-k\n  elif k > v:\n    ans+=v\nprint(ans)", "passed": true, "time": 1.48, "memory": 14116.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\ncount = 0\n\nfor i, j in Counter(a).items():\n    if j-i < 0:\n        count += j\n    else:\n        count += min(j-i, j)\n\nprint(count)", "passed": true, "time": 1.48, "memory": 14208.0, "status": "done"}, {"code": "n=int(input())\na=[int(i) for i in input().split()]\n\ndp=[0]*(n+2)\nfor i in a:\n    if i>n:\n        dp[-1]+=1\n    else:\n        dp[i]+=1\n\nans=dp[-1]\nfor i in range(1,n+1):\n    if dp[i]>=i:\n        ans+=dp[i]-i\n    else:\n        ans+=dp[i]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "import collections\nN=int(input())\na=list(map(int,input().split()))\nc=collections.Counter(a)\nans=0\nfor i,j in c.items():\n  if i>j:\n    ans+=j\n  elif j>i:\n    ans += j-i\nprint(ans)", "passed": true, "time": 0.16, "memory": 14032.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n    n = ini()\n    a = inl()\n    c = Counter()\n    for x in a:\n        c[x] += 1\n    ans = 0\n    for k, v in c.items():\n        if k <= v:\n            ans += v - k\n        else:\n            ans += v\n\n    return ans\n\n\nprint(solve())\n", "passed": true, "time": 0.15, "memory": 14252.0, "status": "done"}, {"code": "from collections import Counter\n\ndef mapt(fn, *args):\n    return tuple(map(fn, *args))\n\n\ndef Input():\n    return mapt(int, input().split(\" \"))\n\n\ndef main():\n    n = int(input())\n    a = Counter(Input())\n    ans = 0\n    for key, val in a.items():\n        x = val - key\n        if x < 0:\n            ans += val\n        elif x > 0:\n            ans += x\n    print(ans)\n\n\nmain()", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "from collections import Counter\n\nN=input()\nlist1=list(map(int,input().split()))\ndict1=Counter(list1)\n\nkey1=list(dict1.keys())\nvalue1=list(dict1.values())\n\nans=0\nfor i in range(len(key1)):\n    x=value1[i]\n    y=key1[i]\n    if x>=y:\n        ans+=x-y\n    else:\n        ans+=x\n\nprint(ans)", "passed": true, "time": 0.24, "memory": 14188.0, "status": "done"}, {"code": "from collections import Counter\ninput();a=Counter(map(int,input().split()))\nprint(sum(j if i>j else j-i for i,j in a.items()))", "passed": true, "time": 0.21, "memory": 14272.0, "status": "done"}, {"code": "import sys\nfrom collections import Counter\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n    n = int(input())\n    a = Counter(list(map(int, input().split())))\n    \n    ans = 0;\n    for k, v in a.items():\n        if k < v:\n            ans += v - k\n        elif k > v:\n            ans += v\n            \n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14356.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().strip().split()))\nd={}\n\nfor n in range(N):\n    if d.get(a[n])==None:\n        d[a[n]]=1\n    else:\n        d[a[n]]+=1\n\ncnt=0\nfor key in list(d.keys()):\n    if key>d[key]:\n        cnt+=d[key]\n    else:\n        cnt+=d[key]-key\n\nprint(cnt)\n", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\nA = Counter(A)\n\ncnt = 0\nfor i, j in list(A.items()):\n    if i > j:\n        cnt += j\n    elif i < j:\n        cnt += j-i\nprint(cnt)\n", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\n\nd = {}\ncnt = 0 \nfor i in range(n):\n    if a[i] not in d:\n        d[a[i]] = 1 \n    else: \n        d[a[i]] += 1\n\nfor key in list(d.keys()):\n    if d[key] != key:\n        if d[key] < key:\n            cnt += d[key]\n        else:\n            cnt += d[key]-key\n\nprint(cnt)\n", "passed": true, "time": 0.15, "memory": 14340.0, "status": "done"}, {"code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate:  2020-10-09 21:07:08 +0900\n# LastModified: 2020-10-09 21:11:06 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom collections import Counter\n\n\ndef main():\n    N = int(input())\n    A = list(map(int, input().split()))\n    A_cnt = Counter(A)\n    ans = 0\n    for key, value in list(A_cnt.items()):\n        if key == value:\n            pass\n        elif key > value:\n            ans += value\n        else:\n            ans += value-key\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "from collections import Counter\nn=int(input())\nL=Counter(list(map(int,input().split())))\nans=0\nfor i in L:\n    if i!=L[i]:\n        if L[i]-i>0:\n            ans=ans+L[i]-i\n        else:ans+=L[i]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nd = dict()\nfor i in range(N):\n    if d.get(A[i]) is None:\n        d[A[i]] = 1\n    else:\n        d[A[i]] += 1\nans = 0\nfor key, value in list(d.items()):\n    if key <= value:\n        ans += value - key\n    else:\n        ans += value\nprint(ans)\n\n\n", "passed": true, "time": 0.38, "memory": 14312.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\nc = Counter(map(int, input().split()))\nans = 0\nfor i in c:\n    if c[i]>i:\n        ans += c[i]-i\n    elif c[i]<i:\n        ans += c[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "import collections\nn = int(input())\na = list(map(int,input().split()))\n\na_cnt = collections.Counter(a)\n#print(a_cnt)\ncnt = 0\nfor item in a_cnt.items():\n    if item[0]<item[1]:\n        cnt += item[1]-item[0]\n    elif item[0]>item[1]:\n        cnt += item[1]\nprint(cnt)", "passed": true, "time": 0.23, "memory": 14280.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nans = 0\ndict = {}\nfor i in range(N):\n    if A[i] in dict:\n        dict[A[i]] += 1\n    else:\n        dict[A[i]] = 1\n#print(dict)\nfor x in dict:\n    if x > dict[x]:\n        ans += dict[x]\n    else:\n        ans += dict[x]-x\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ns = set(a)\n\nd = {}\nfor i in s:\n    d[i] = 0\nfor i in a:\n    d[i] += 1\n\nans = 0\nfor i in d:\n    c = d[i]\n    if c < i:\n        ans += c\n    elif c >= i:\n        ans += c - i\nprint(ans)", "passed": true, "time": 0.23, "memory": 14256.0, "status": "done"}, {"code": "import collections as c\n\nn = int(input())\ns = list(map(int,input().split()))\ns = c.Counter(s)\nans = 0\nfor i in s.items():\n    a = i[0]\n    b = i[1]\n    if b<a:\n        ans += b\n    else:\n        ans += b-a\nprint(ans)", "passed": true, "time": 0.19, "memory": 14276.0, "status": "done"}, {"code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\nans = 0\nfor k in c.keys():\n  if k > c[k]:\n    ans += c[k]\n  elif k < c[k]:\n    ans += c[k] - k\nprint(ans)", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "import sys\nimport math\nfrom collections import Counter\n\n\ninint = lambda: int(sys.stdin.readline())\ninintm = lambda: map(int, sys.stdin.readline().split())\ninintl = lambda: list(inintm())\ninstrm = lambda: map(str, sys.stdin.readline().split())\ninstrl = lambda: list(instrm())\n\nn = inint()\nA = inintl()\n\nC = Counter(A)\nans = 0\n\nfor c in C:\n    if c > C[c]:\n        ans += C[c]\n    elif c < C[c]:\n        ans += C[c] - c\n\nprint(ans)", "passed": true, "time": 0.25, "memory": 14192.0, "status": "done"}, {"code": "from collections import Counter\n \nN = input()\nA = list(map(int, input().split()))\n \ncounter = Counter(A)\n \ncnt = 0\nfor k, v in counter.items():\n    if v < k:\n        cnt += v\n    elif v > k:\n        cnt += v - k\n \n \nprint(cnt)", "passed": true, "time": 0.17, "memory": 14112.0, "status": "done"}, {"code": "N=int(input())\n\na=list(map(int,input().split()))\n\na.sort()\nc=1\nans=0\nfor i in range(N-1):\n    if a[i]==a[i+1]:\n        c+=1\n        if c>a[i]:\n            ans+=1\n    else:\n        if c<a[i]:\n            ans+=c\n            c=1\n        else:\n            c=1\nif c<a[N-1]:\n    ans+=c\n\nprint(ans)\n", "passed": true, "time": 0.18, "memory": 14188.0, "status": "done"}, {"code": "#\n# abc082 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import Counter\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"4\n3 3 3 3\"\"\"\n        output = \"\"\"1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"5\n2 4 1 4 2\"\"\"\n        output = \"\"\"2\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_3(self):\n        input = \"\"\"6\n1 2 2 3 3 3\"\"\"\n        output = \"\"\"0\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_4(self):\n        input = \"\"\"1\n1000000000\"\"\"\n        output = \"\"\"1\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_5(self):\n        input = \"\"\"8\n2 7 1 8 2 8 1 8\"\"\"\n        output = \"\"\"5\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N = int(input())\n    A = tuple(map(int, input().split()))\n    C = Counter(A)\n\n    ans = 0\n    for k, v in list(C.items()):\n        if v > k:\n            ans += v - k\n        elif v < k:\n            ans += v\n\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14620.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nans = 0\nA.sort()\n\ncount = 0\nm = 0\n\nfor i in range(N):\n  if count == 0:\n    m = A[i]\n    count += 1\n  elif A[i] == m:\n    count += 1\n  else:\n    if m > count:\n      ans += count\n    else:\n      ans += count-m\n    count = 1\n    m = A[i]\n\nif m > count:\n  ans += count\nelse:\n  ans += count-m\n\nprint(ans)", "passed": true, "time": 0.19, "memory": 14180.0, "status": "done"}, {"code": "from collections import Counter\ninput();a=Counter(map(int,input().split()))\nprint(sum([j if i>j else j-i for i,j in a.items()]))", "passed": true, "time": 0.14, "memory": 14028.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = Counter(list(map(int, input().split())))\ncnt = 0\nfor x,y in a.items():\n    if x==y: continue\n    if x>y: cnt += y\n    else: cnt += y-x\nprint(cnt)", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "import collections\nn=int(input())\na=list(map(int,input().split()))\nl=list(set(a))\nm=collections.Counter(a)\nans=0\nfor i in range(len(l)):\n    if m[l[i]]<l[i]:\n        ans+=m[l[i]]\n    else:\n        ans+=m[l[i]]-l[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14364.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nd = dict()\nfor i in a:\n    if i not in d:\n        d[i] = 1\n\n    else:\n        d[i] += 1\ncount = 0\nfor key, value in list(d.items()):\n    if int(key) > value:\n        count += int(value)\n    elif int(key) < value:\n        count += value - int(key)\n\nprint(count)\n", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int,input().split()))\nimport collections\nA = collections.Counter(a)\nans = 0\nfor i,j in A.items():\n    if j > i:\n        ans += j-i\n    elif i > j:\n        ans += j\nprint(ans)", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "n = int(input())\nalist = list(map(int,input().split()))\nfrom collections import Counter\nadic = Counter(alist)\ncount = 0\nfor k,v in adic.items():\n  if int(k) <= v:\n    count+=(v-int(k))\n  else:\n    count+=v\nprint(count)", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "def count(list):\n    dict = {}\n    for i in range(len(list)):\n        dict[list[i]] = dict.get(list[i], 0) + 1\n    return dict\n\nn = int(input())\na = list(map(int,input().split()))\ndic = count(a)\nans = 0\n\nfor i, x in dic.items():\n    differ = x - i\n    if differ>0:\n        ans += differ\n    elif differ<0:\n        ans += x\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "N = int(input())\na = [int(s) for s in input().split()]\np = {}\n\nfor b in a:\n    if b in p:\n        p[b] += 1\n    else:\n        p[b] = 1\n\nans = 0\nfor k in p:\n    if k > p[k]:\n        ans += p[k]\n    elif k < p[k]:\n        ans += (p[k] - k)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "import collections as c\ninput();print(sum(j if i>j else j-i for i,j in c.Counter(map(int,input().split())).items()))", "passed": true, "time": 0.14, "memory": 14064.0, "status": "done"}, {"code": "from collections import Counter\nans = 0\n_ = input()\na = list(map(int, input().split()))\nfor k,v in Counter(a).items():\n    if k > v:\n        ans += v\n    elif k < v:\n        ans += v-k\nprint(ans)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\n\na=sorted(a)\nl=a[0]\ncnt=0\n\nb=[]\nfor i in range(N):\n    if a[i]==l:\n        cnt+=1\n    else:\n        b.append([l,cnt])\n        l=a[i]\n        cnt=1\nif cnt>0:\n    b.append([l,cnt])\n\nans=0\nfor i in range(len(b)):\n    if b[i][0]>b[i][1]:\n        ans+=b[i][1]\n    else:\n        ans+=b[i][1]-b[i][0]\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14104.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nimport collections\na = collections.Counter(a)\nans = 0\nfor i,j in list(a.items()):\n    if i>j:\n        ans += j\n    else:\n        ans += abs(i-j)\nprint(ans)\n", "passed": true, "time": 0.34, "memory": 14268.0, "status": "done"}, {"code": "from collections import Counter\n\nN = int(input())\nD = list(map(int,input().split()))\n\nCD = Counter(D)\nCD=list(CD.items())\ncount=0\nfor i in range(len(CD)):\n    if CD[i][0]<CD[i][1]:\n        count=count+CD[i][1]-CD[i][0]\n    elif CD[i][0]>CD[i][1]:\n        count=count+CD[i][1]\nprint(count)", "passed": true, "time": 0.23, "memory": 14292.0, "status": "done"}, {"code": "n = int(input())\n#a, b = map(int,input().split())\nal = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nans = 0\ndic = {}\nfor a in al:\n    dic[a] = dic.get(a, 0)+1\n\nfor k, v in dic.items():\n    if k == v:\n        pass\n    elif k < v:\n        ans += v-k\n    else:\n        ans += v\nprint(ans)", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\n\ncnt_A = Counter(A)\n\nans = 0\nfor k, v in cnt_A.items():\n    if v - k >= 0:\n        ans += v - k\n    else:\n        ans += v\nprint(ans)", "passed": true, "time": 0.15, "memory": 14032.0, "status": "done"}, {"code": "import math\nfrom collections import Counter\nfrom itertools import product\n\nii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\nn = ii()\na = li()\n\ncnt = Counter(a)\nans = 0\nfor i,j in cnt.items():\n    if i > j:\n        ans += j\n    else:\n        ans += j - i\nprint(ans)", "passed": true, "time": 0.27, "memory": 14108.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n    from collections import Counter\n    ans = 0\n    for k, v in list(Counter(a).items()):\n        ans += v - k if v >= k else v\n    return ans\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n    def iterate_tokens():\n        for line in sys.stdin:\n            for word in line.split():\n                yield word\n    tokens = iterate_tokens()\n    N = int(next(tokens))  # type: int\n    a = [int(next(tokens)) for _ in range(N)]  # type: \"List[int]\"\n    print((solve(N, a)))\n\ndef test():\n    import doctest\n    doctest.testmod()\n\ndef __starting_point():\n    #test()\n    main()\n\n__starting_point()", "passed": true, "time": 0.23, "memory": 14264.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\ncnt = dict()\n\nfor ai in a:\n    if ai not in list(cnt.keys()):\n        cnt[ai] = 1\n    else:\n        cnt[ai] += 1\n\nans = 0\nfor k in list(cnt.keys()):\n    if cnt[k] > k:\n        ans += cnt[k] - k\n    elif cnt[k] < k:\n        ans += cnt[k]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int,input().split()))\nc = collections.Counter(a)\n\ncnt = 0\nfor k,v in list(c.items()):\n  cnt += min(v-k,v) if v-k >=0 else v\nprint(cnt)\n", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n  return list(map(int,readline().split()))\ndef readTuples():\n    return tuple(map(int,readline().split()))\ndef I():\n    return int(readline())\nn = I()\nCount = Counter(readInts())\nans = 0\nfor k,v in list(Count.items()):\n    if k < v:\n        ans += v - k\n    if v < k:\n        ans += v\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14388.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\naa = Counter(map(int, input().split()))\nans = 0\nfor k, v in aa.items():\n    if k < v:\n        ans += v - k\n    elif k > v:\n        ans += v\nprint(ans)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "from collections import Counter\n\n_ = input()\na = [int(i) for i in input().split()]\n\nans = 0\nfor k, v in Counter(a).items():\n    if k < v:\n        ans += v - k\n    elif v < k:\n        ans += v\nelse:\n    print(ans)", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "import collections\nn = int(input())\naa = list(map(int, input().split()))\ncc = collections.Counter(aa)\ncnt = 0\nfor c in list(cc.items()):\n  if c[0] > c[1]:\n    cnt += c[1]\n  elif c[0] == c[1]:\n    continue\n  elif c[0] < c[1]:\n    cnt += c[1]-c[0]\nprint(cnt)\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\ncount = Counter(a)\nans = 0\nfor k,v in count.items():\n  if k < v: ans += v-k\n  elif v < k: ans += v\nprint(ans)", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\na.append(10**10)\na.sort()\nn=0\nc=0\nans=0\nfor i in range(N+1):\n    if n!=a[i]:\n        if n<c:ans+=c-n\n        elif c<n:ans+=c\n        n=a[i]\n        c=1\n    else:c+=1\nprint(ans)", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "import collections\nN = int(input())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nans = 0\nfor i in counterA.keys():\n    if i == counterA[i]:\n        continue\n    if i < counterA[i]:\n        ans += counterA[i]-i\n    elif i > counterA[i]:\n        ans += counterA[i]\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14392.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\n\nd = {}\nfor a in A:\n    d[a] = d.get(a, 0) + 1\n\nans = 0\nfor a in d:\n    if d[a]>a:\n        ans += d[a]-a\n    elif d[a]<a:\n        ans += d[a]\nprint(ans)", "passed": true, "time": 0.15, "memory": 14256.0, "status": "done"}, {"code": "import collections\n\nN = int(input())\na = list(map(int,input().split()))\nans = 0\n\naa = collections.Counter(a).most_common()\n#print(aa)\n\nfor i,j in aa:\n    if i > j:\n        ans += j\n    if i < j:\n        ans += j-i\n    \nprint(ans)", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "from collections import Counter\nN = int(input())\nC = Counter(map(int, input().split()))\nans = 0\nfor i in C:\n    if C[i]>i:\n        ans += C[i]-i\n    elif C[i]<i:\n        ans += C[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14140.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\nal = list(map(int, input().split()))\nc = Counter(al)\n\nans = 0\nfor k, v in list(c.items()):\n    if k == v:\n        continue\n    elif k > v:\n        ans += v\n    else:\n        ans += v-k\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14356.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\nN = int(input())\n#= input()\n#= map(int, input().split())\nA = list(map(int, input().split()))\n#= [input(), input()]\n#= [list(map(int, input().split())) for _ in range(N)]\n#= [int(input()) for _ in range(N)]\n#= {i:[] for i in range(N)}\n\ndic = {}\n\nfor a in A:\n    if a in dic:\n        dic[a] += 1\n    else:\n        dic[a] = 1\n\nans = 0\n\nfor key in dic:\n    if dic[key] != key:\n        if dic[key] > key:\n            ans += dic[key] - key\n        else:\n            ans += dic[key]\n\nprint(ans)", "passed": true, "time": 0.24, "memory": 14236.0, "status": "done"}, {"code": "N = int(input())\na = list(map(int, input().split()))\n\na_dic = {}\n\nfor i in range(N):\n  if a[i] not in a_dic.keys():\n    a_dic[a[i]] = 1\n  else:\n    a_dic[a[i]] += 1\n    \nans = 0\n\nfor i in a_dic.keys():\n  if a_dic[i] >= i:\n    ans += a_dic[i] - i\n  elif a_dic[i] < i:\n    ans += a_dic[i]\n    \nprint(ans)", "passed": true, "time": 0.23, "memory": 14156.0, "status": "done"}, {"code": "N=int(input())\nlst=list(map(int,input().split()))\nlst.sort()\nfreq={}\nfor i in lst:\n    if i in freq:\n        freq[i]+=1\n    else:\n        freq[i]=1\nans=0\nfor key,value in freq.items():\n    if key>value:\n        ans+=value\n    elif key<value:\n        ans+=abs(key-value)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nhindo=dict()\nfor i in a:\n    if i in hindo:\n        hindo[i]+=1\n    else:\n        hindo[i]=1\nans=0\nfor num,cnt in hindo.items():\n    if num==cnt:\n        continue\n    else:\n        if num>cnt:\n            ans+=cnt\n        else:\n            ans+=cnt-num\nprint(ans)", "passed": true, "time": 0.14, "memory": 14228.0, "status": "done"}, {"code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\nans = 0\nfor e in c:\n  if e < c[e]:\n    ans += c[e] - e\n  elif e > c[e]:\n    ans += c[e]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "from collections import Counter\nans = 0\n_ = input()\na = Counter(map(int, input().split()))\nfor k,v in a.items():\n    if k > v:\n        ans += v\n    elif k < v:\n        ans += v-k\nprint(ans)", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nc = collections.Counter(a)\nans = 0\n\nfor k, v in list(c.items()):\n    if k > v:\n        ans += v\n    if k < v:\n        ans += v - k\n    \nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "N=int(input())\na=list(map(int,input().split()))\na.sort()\na.append(0)\ni=0\nans=0\nwhile i<N:\n    x=a[i]\n    count=0\n    while a[i]==x:\n        i+=1\n        count+=1\n    if count<x:\n        ans+=count\n    else:\n        ans+=count-x\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14372.0, "status": "done"}, {"code": "from collections import Counter\n\ninput()\na = Counter(map(int, input().split()))\nprint(sum(v - k if k <= v else v for k, v in a.items()))", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "n = int(input())\ndic = {}\n\nA = list(map(int, input().split()))\n\nfor a in A:\n    if a in dic:\n        dic[a] += 1\n    else:\n        dic[a] = 1\n\nans = 0\n\nfor key in dic:\n    if dic[key] != key:\n        if dic[key] > key:\n            ans += dic[key] - key\n        else:\n            ans += dic[key]\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14224.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\nA = Counter(list(map(int, input().split())))\nans = 0\nfor k, v in list(A.items()):\n    if k > v:\n        ans += v\n    elif k < v:\n        ans += v - k\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14300.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\nd = Counter(list(map(int, input().split())))\n\nans = 0\nfor k, v in d.items():\n    if k > v:\n        ans += v\n    elif k < v:\n        ans += v-k\nprint(ans)", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "from collections import Counter\n\nN = input()\nA = list(map(int, input().split()))\n\ncounter = Counter(A)\n\ncnt = 0\nfor k, v in list(counter.items()):\n    if v < k:\n        cnt += v\n    elif v > k:\n        cnt += v - k\n\n\nprint(cnt)\n", "passed": true, "time": 0.24, "memory": 13900.0, "status": "done"}, {"code": "import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nc = collections.Counter(a)\n\nans = 0\n\nfor i in c.keys():\n    if(c[i] >= i):\n        ans += c[i] - i\n    else:\n        ans += c[i]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "N = input()\nA = sorted([int(x) for x in input().split()])\nimport bisect as bs\nans = 0\nf = lambda X, x: bs.bisect_right(X,x) - bs.bisect_left(X,x)\nfor a in set(A):\n    cnt = f(A,a)\n    if cnt < a:\n        ans += cnt\n    else:\n        ans += cnt-a\nprint(ans)", "passed": true, "time": 0.24, "memory": 13900.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nb = Counter(a)\nans = 0\nfor i in set(a):\n    if b[i] < i:\n        ans += b[i]\n    else:\n        ans += b[i]-i\nprint(ans)", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}, {"code": "import collections\nn = int(input())\nA = list(map(int,input().split()))\nC = collections.Counter(A)\nans = 0\n\nfor k,v in C.items():\n  if k == v: continue\n  elif k < v: ans += (v - k)\n  else: ans += v\n\nprint(ans)", "passed": true, "time": 0.19, "memory": 14280.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\n\nvalues = {}\ncnt = n\n\nfor i in range(n):\n    if a[i] in values:\n        values[a[i]] += 1\n    else:\n        values[a[i]] = 1\n\n    if values[a[i]] == a[i]:\n            cnt -= a[i]\n\nprint(cnt)", "passed": true, "time": 0.15, "memory": 14224.0, "status": "done"}, {"code": "\nfrom collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\n\nD = defaultdict(int)\nfor a in A:\n  D[a] += 1\n\nans = 0\nfor a, x in D.items():\n  if x >= a:\n    ans += x-a\n  else:\n    ans += x\n\nprint(ans)", "passed": true, "time": 0.22, "memory": 14292.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n    if a[i] not in num_map:\n        num_map[a[i]] = 1\n    else:\n        num_map[a[i]] += 1\n\nres = 0\nfor key, value in list(num_map.items()):\n    if key <= value:\n        res += value - key\n    else:\n        res += value\n\nprint(res)\n", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "def main():\n    n = int(input())\n    a_lst = list(map(int, input().split()))\n    a_lst.sort()\n    a_set_lst = list(set(a_lst))\n    a_set_lst.sort()\n\n    count_lst = []\n    count = 1\n    if n == 1:\n        count_lst.append(count)\n    else:\n        for i in range(n - 1):\n            a1 = a_lst[i]\n            a2 = a_lst[i + 1]\n\n            if a1 == a2:\n                count += 1\n                if i == n - 2:\n                    count_lst.append(count)\n            else:\n                count_lst.append(count)\n                count = 1\n        if a_lst[-1] != a_lst[-2]:\n            count_lst.append(count)\n\n    minimum = 0\n    for i in range(len(a_set_lst)):\n        number = a_set_lst[i]\n        count = count_lst[i]\n\n        if count < number:\n            minimum += count\n        else:\n            minimum += count - number\n\n    print(minimum)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "from collections import Counter\nN = int(input())\na = list(map(int, input().split()))\na_counter = Counter(a)\n\nans = 0\n\nif N == 1 and a[0] != 1:\n    print(1)\n    return\nelif N == 1 and a[0] == 1:\n    print(0)\n    return\n\n\nfor i in (a_counter.items()):\n    key = (i[0])\n    value = (i[1])\n\n    if key == value:\n        pass\n    \n    elif key < value:\n        ans = ans + (value - key)\n    else:\n        ans = ans + (value) \n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14244.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = Counter(list(map(int, input().split())))\n\nans = 0\nfor x,y in a.items():\n    if x<y: ans += y-x\n    elif y<x: ans += y\nprint(ans)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\na = Counter(a).most_common()\nnum = 0\nfor i,j in a:\n    if i < j:\n        num += (j-i)\n    elif j < i:\n        num += j\nprint(num)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**6)\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nc = Counter(a)\n\nans = 0\nfor i in sorted(c.keys()):\n    if c[i] < i:\n        ans += c[i]\n    elif c[i] == i:\n        continue\n    elif c[i] > i:\n        ans += c[i]-i\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\nca = Counter(a)\nans = 0\nfor k in list(ca.keys()):\n    if ca[k] > k:\n        ans += ca[k] - k\n    elif ca[k] < k:\n        ans += ca[k]\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: list(map(int, INPUT().split()))\nS_MAP = lambda: list(map(str, INPUT().split()))\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n    N = INT()\n    A = LIST()\n\n    c = Counter(A)\n    ans = 0\n    for k, v in list(c.items()):\n        if k < v:\n            ans += v - k\n        elif k > v:\n            ans += v\n\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 15:39:14 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [int(x) for x in input().split()]\nd = [0]*N\nans = 0\nfor a in A:\n    if a > N :\n        ans += 1\n    else:\n        d[a-1] += 1\n\nfor i in range(N):\n    if d[i] > 0:\n        if d[i] > i+1:\n            ans += d[i] - (i+1)\n        if d[i] < i+1:\n            ans += d[i]\n#print(d)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14096.0, "status": "done"}, {"code": "from collections import Counter\ninput();print(sum(j if i>j else j-i for i,j in Counter(map(int,input().split())).items()))", "passed": true, "time": 0.14, "memory": 14260.0, "status": "done"}, {"code": "from collections import Counter\nfrom itertools import starmap\ndef main():\n    N = input()\n    A = list(map(int, input().split()))\n    count = Counter(A)\n    remove = lambda x,y: y-x if y >= x else y\n    ans = sum(starmap(remove, count.items()))\n    print(ans)\n\nmain()", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "n = int(input())\na = [int(x) for x in input().split()]\na.sort()\nflag = [False] * n\nres = 0\n\nfor i in range(n):\n  if flag[i]:\n    continue\n  \n  c = 0\n  j = i\n  \n  while a[i] == a[j]:\n    c += 1\n    flag[j] = True\n    j += 1\n    if j == n:\n      break\n  \n  if c == a[i] or c == 0:\n    continue\n  elif c < a[i]:\n    res += c\n  else:\n    res += c - a[i]\n    \nprint(res)", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}]