import numpy as np

N = int(eval(input()))

lst = [int(x) for x in input().split()]



lst2 = np.zeros((max(lst), N))

for idx, n in enumerate(lst):

    lst2[:n,idx] = 1



ret = 0

for x in lst2:

    flg = True

    for y in x:

        if flg and y == 1:

            ret += 1

            flg = False

        elif y == 0:

            flg = True

print(ret)
N = int(eval(input()))

lst = [int(x) for x in input().split()]



n = max(lst)

h = 1

ret = 0

while n >= h:

    flg = True

    for x in lst:

        if x >= h and flg:

            ret += 1

            flg = False

        elif h > x:

            flg = True

    h += 1

print(ret)
import numpy as np

N = int(eval(input()))
lst = [int(x) for x in input().split()]
lst2 = np.zeros((max(lst), N))
for idx, n in enumerate(lst):
    lst2[:n, idx] = 1
ret = 0
for x in lst2:
    flg = True
    for y in x:
        if flg and y == 1:
            ret += 1
            flg = False
        elif y == 0:
            flg = True
print(ret)

N = int(eval(input()))
lst = [int(x) for x in input().split()]
n = max(lst)
h = 1
ret = 0
while n >= h:
    flg = True
    for x in lst:
        if x >= h and flg:
            ret += 1
            flg = False
        elif h > x:
            flg = True
    h += 1
print(ret)

-import numpy as np - -lst2 = np.zeros((max(lst), N)) -for idx, n in enumerate(lst): -    lst2[:n, idx] = 1 +n = max(lst) +h = 1 -for x in lst2: +while n >= h: -    for y in x: -        if flg and y == 1: +    for x in lst: +        if x >= h and flg: -        elif y == 0: +        elif h > x: +    h += 1