Polycarp wants to train before another programming competition. During the first day of his training he should solve exactly $1$ problem, during the second day — exactly $2$ problems, during the third day — exactly $3$ problems, and so on. During the $k$-th day he should solve $k$ problems.

Polycarp has a list of $n$ contests, the $i$-th contest consists of $a_i$ problems. During each day Polycarp has to choose exactly one of the contests he didn't solve yet and solve it. He solves exactly $k$ problems from this contest. Other problems are discarded from it. If there are no contests consisting of at least $k$ problems that Polycarp didn't solve yet during the $k$-th day, then Polycarp stops his training.

How many days Polycarp can train if he chooses the contests optimally?


-----Input-----

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of contests.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$) — the number of problems in the $i$-th contest.


-----Output-----

Print one integer — the maximum number of days Polycarp can train if he chooses the contests optimally.


-----Examples-----
Input
4
3 1 4 1

Output
3

Input
3
1 1 1

Output
1

Input
5
1 1 1 2 2

Output
2
[{"code": "def main():\n    n = int(input())\n    arr = sorted(map(int, input().split()))\n    j = 1\n    for x in arr:\n        if x >= j:\n            j += 1\n    print(j - 1)\n    return 0\n\nmain()", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "n = int(input())\nl = sorted(map(int, input().split()))\ni = 0\nres = 0\nwhile i < n:\n    if res < l[i]:\n        res += 1\n    i += 1\nprint(res)", "passed": true, "time": 0.15, "memory": 14116.0, "status": "done"}, {"code": "# AC\nimport sys\n\n\nclass Main:\n    def __init__(self):\n        self.buff = None\n        self.index = 0\n\n    def __next__(self):\n        if self.buff is None or self.index == len(self.buff):\n            self.buff = self.next_line()\n            self.index = 0\n        val = self.buff[self.index]\n        self.index += 1\n        return val\n\n    def next_line(self):\n        return sys.stdin.readline().split()\n\n    def next_ints(self):\n        return [int(x) for x in sys.stdin.readline().split()]\n\n    def next_int(self):\n        return int(next(self))\n\n    def solve(self):\n        n = self.next_int()\n        x = sorted(self.next_ints())\n        res = 0\n        for _x in x:\n            if _x > res:\n                res += 1\n        print(res)\n\n\ndef __starting_point():\n    Main().solve()\n\n__starting_point()", "passed": true, "time": 0.23, "memory": 14348.0, "status": "done"}, {"code": "n = int(input())\nA = list(map(int, input().split()))\nA.sort()\nk = 1\nfor i in A:\n    if i >= k:\n        k += 1\nprint(k - 1)", "passed": true, "time": 0.14, "memory": 14072.0, "status": "done"}, {"code": "n = int(input())\na = sorted(list(map(int, input().split())))\ncount = 0\nh = 1\nfor i in range(n):\n    if a[i] >= h:\n        h += 1\n        count += 1\nprint(count)", "passed": true, "time": 0.24, "memory": 14128.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\nsa = sorted(a)\nptr = 0\nfor i in range(1, n + 2):\n    while ptr < n and sa[ptr] < i:\n        ptr += 1\n    if ptr == n:\n        print(i - 1)\n        break\n    ptr += 1\n", "passed": true, "time": 0.24, "memory": 14232.0, "status": "done"}, {"code": "n = int(input())\nu = list(map(int, input().split()))\nu.sort()\nans = 0\nfor i in range(n):\n    if ans < u[i]:\n        #5print(ans, u[i])\n        ans += 1\nprint(ans)\n", "passed": true, "time": 0.24, "memory": 14236.0, "status": "done"}, {"code": "def main():\n    from sys import stdin, stdout\n\n    def read():\n        return stdin.readline().rstrip('\\n')\n\n    def read_array(sep=None, maxsplit=-1):\n        return read().split(sep, maxsplit)\n\n    def read_int():\n        return int(read())\n\n    def read_int_array(sep=None, maxsplit=-1):\n        return [int(a) for a in read_array(sep, maxsplit)]\n\n    def write(*args, **kwargs):\n        sep = kwargs.get('sep', ' ')\n        end = kwargs.get('end', '\\n')\n        stdout.write(sep.join(str(a) for a in args) + end)\n\n    def write_array(array, **kwargs):\n        sep = kwargs.get('sep', ' ')\n        end = kwargs.get('end', '\\n')\n        stdout.write(sep.join(str(a) for a in array) + end)\n\n    n = read_int()\n    a = read_int_array()\n    a.sort()\n    out = 0\n    for x in a:\n        if x >= out + 1:\n            out += 1\n    write(out)\n\nmain()\n", "passed": true, "time": 0.22, "memory": 14224.0, "status": "done"}, {"code": "n = int(input())\ns = sorted([int(i) for i in input().split()])\nneed = 1\nfor i in s:\n\tif i >= need:\n\t\tneed += 1\nprint (need - 1)", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "IN = input\nrint = lambda: int(IN())\nrmint = lambda: list(map(int, IN().split()))\nrlist = lambda: list(rmint())\n\nn = rint()\na = rlist()\na.sort()\nk = 1\nfor c in a:\n    if c >= k: k += 1\nprint(k-1)\n", "passed": true, "time": 0.23, "memory": 14072.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int, input().split()))\na.sort()\ncontest = 1\nfor i in range(n):\n    if a[i] >= contest:\n        contest += 1\nprint(contest-1)\n", "passed": true, "time": 0.22, "memory": 14272.0, "status": "done"}, {"code": "n=int(input())\nA=list(map(int,input().split()))\nA.sort()\nANS=1\n\nfor a in A:\n    if a>=ANS:\n        ANS+=1\n\nprint(ANS-1)\n", "passed": true, "time": 0.14, "memory": 14236.0, "status": "done"}, {"code": "n=int(input())\na=[int(s) for s in input().split()]\na.sort()\ncur=1\nans=0\nfor i in range(n):\n    if a[i]>=cur:\n        cur+=1\n        ans+=1\nprint(ans)", "passed": true, "time": 0.15, "memory": 14120.0, "status": "done"}, {"code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\ncount=0\nfor i in l:\n\tif i>count:\n\t\tcount+=1\nprint (count)", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "n = int(input())\nt = list(map(int,input().split()))\nt.sort()\ncount=0\nfor i in range(n):\n\tif(t[i]>=count+1):\n\t\tcount+=1\nprint(count)", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "n=int(input())\na=sorted(list(map(int,input().split())))\nans=0\nk=1\nfor i in a:\n    if i>=k:\n        ans+=1\n        k+=1\nprint(ans)", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "n=int(input())\nl1=list(map(int,input().split()))\nl1.sort()\ni=0\nans=0\nwhile i<len(l1):\n    if l1[i]>=ans+1:\n        i+=1\n        ans+=1\n    else :\n        i+=1\nprint(ans)", "passed": true, "time": 0.14, "memory": 14028.0, "status": "done"}, {"code": "n = int(input())\nlst = list(map(int, input().split()))\nlst.sort()\ndayCount = 0\nfor i in lst:\n    if i >= dayCount+1:\n        dayCount += 1\nprint(dayCount)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "n = int(input())\nl = list(map(int, input().split()))\nl.sort(    )\nk = 1\nfor i in l:\n    if i >= k:\n        k += 1\nprint(k - 1)", "passed": true, "time": 0.14, "memory": 14072.0, "status": "done"}, {"code": "#n = int(input())\n#n, m = map(int, input().split())\n#d = list(map(int, input().split()))\n\nn = int(input())\nd = sorted(map(int, input().split()))\n\nr = 0\nj = 1\nfor i in range(n):\n    if j <= d[i]:\n        r+=1\n        j+=1\nprint(r)\n\n\n", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "n = int(input())\nsp = list(map(int, input().split()))\nsp.sort()\nk = 1\nind = 0\nwhile ind != n:\n\tif sp[ind] >= k:\n\t\tk += 1\n\tind += 1\nprint(k - 1)\n", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "import math\nimport bisect\nimport heapq\nfrom collections import defaultdict\n\n\ndef egcd(a, b):\n    if a == 0:\n        return (b, 0, 1)\n    else:\n        g, x, y = egcd(b % a, a)\n        return (g, y - (b // a) * x, x)\n\n\ndef mulinv(b, n):\n    g, x, _ = egcd(b, n)\n    if g == 1:\n        return x % n\n\n\n\ndef isprime(n):\n    for d in range(2, int(math.sqrt(n))+1):\n        if n % d == 0:\n            return False\n    return True\n\n\ndef argsort(ls):\n    return sorted(range(len(ls)), key=ls.__getitem__)\n\n\ndef f(p=0):\n    if p == 1:\n        return map(int, input().split())\n    elif p == 2:\n        return list(map(int, input().split()))\n    elif p == 3:\n        return list(input())\n    else:\n        return int(input())\n\n\nn = f()\ncl = sorted(f(2))\ncount = cl[-1]\nres = n\nfor i in range(n-2, -1, -1):\n    count = min(cl[i], count-1)\n    if count==0:\n        res = n-i-1\n        break\n\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "n=int(input())\na=[int(x) for x in input().split()]\na.sort()\ncounter=0\ni=1\nuk=0\nwhile uk<n:\n    if a[uk]<i:\n        uk+=1\n    else:\n        counter+=1\n        uk+=1\n        i+=1\nprint(counter)\n    \n", "passed": true, "time": 0.14, "memory": 14196.0, "status": "done"}, {"code": "n = int(input())\nmas = [int(i) for i in input().split()]\nmas = sorted(mas)\nk = 1\nfor i in range(n):\n    if mas[i] >= k:\n        k += 1\nprint(k-1)", "passed": true, "time": 0.14, "memory": 14020.0, "status": "done"}]