Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int,input().split()))

su = 0

co = 0

for i in range(max(a)):
    for j in range(n):
        if a[j] > 0 and co == 0:
            co += 1
            su += 1
        if co  >=  1:
            if a[j] == 0:
                co = 0
            else:
                a[j] -= 1
    co = 0

print(su)



Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({5,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min(5,k-i)):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min(5,k-i+1)):
    p.append(d[i:i+j+1])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])


Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min(5,k-i+1)):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  if i <= k-6:
    for j in range(5):
      if i + j + 1 <= k-1:
        p.append(d[i:i+j+1])
  else:
    for j in range(k - i):
      p.append(d[i:i+j+1])
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(5):
    if i + j + 1 <= k-1:
      p.append(d[i:i+j+1])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(k-i+1):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]

print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])

Buggy python submission (verdict: Runtime Error):
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(k-i):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]

print(x[a-1])

Fixed submission:
d = input()
a = int(input())
p = []
k = len(d)
for i in range(k):
  for j in range(min({6,k-i+1})):
    p.append(d[i:i+j])
    
x = list(set(p))
x.sort()
del x[0]
 
print(x[a-1])