Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.

 [Image] 

The girl lives in house m of a village. There are n houses in that village, lining in a straight line from left to right: house 1, house 2, ..., house n. The village is also well-structured: house i and house i + 1 (1 ≤ i < n) are exactly 10 meters away. In this village, some houses are occupied, and some are not. Indeed, unoccupied houses can be purchased.

You will be given n integers a_1, a_2, ..., a_{n} that denote the availability and the prices of the houses. If house i is occupied, and therefore cannot be bought, then a_{i} equals 0. Otherwise, house i can be bought, and a_{i} represents the money required to buy it, in dollars.

As Zane has only k dollars to spare, it becomes a challenge for him to choose the house to purchase, so that he could live as near as possible to his crush. Help Zane determine the minimum distance from his crush's house to some house he can afford, to help him succeed in his love.


-----Input-----

The first line contains three integers n, m, and k (2 ≤ n ≤ 100, 1 ≤ m ≤ n, 1 ≤ k ≤ 100) — the number of houses in the village, the house where the girl lives, and the amount of money Zane has (in dollars), respectively.

The second line contains n integers a_1, a_2, ..., a_{n} (0 ≤ a_{i} ≤ 100) — denoting the availability and the prices of the houses.

It is guaranteed that a_{m} = 0 and that it is possible to purchase some house with no more than k dollars.


-----Output-----

Print one integer — the minimum distance, in meters, from the house where the girl Zane likes lives to the house Zane can buy.


-----Examples-----
Input
5 1 20
0 27 32 21 19

Output
40
Input
7 3 50
62 0 0 0 99 33 22

Output
30
Input
10 5 100
1 0 1 0 0 0 0 0 1 1

Output
20


-----Note-----

In the first sample, with k = 20 dollars, Zane can buy only house 5. The distance from house m = 1 to house 5 is 10 + 10 + 10 + 10 = 40 meters.

In the second sample, Zane can buy houses 6 and 7. It is better to buy house 6 than house 7, since house m = 3 and house 6 are only 30 meters away, while house m = 3 and house 7 are 40 meters away.

Difficulty: interview

Starter code:

Solutions:
n, m, k = list(map(int, input().split()))
m -= 1
line = list(map(int, input().split()))
answer = n
for i in range(n):
    if line[i] == 0:
        continue
    if line[i] > k:
        continue
    answer = min(answer, abs(m - i))
print(answer * 10)

n,m,k=[int(i) for i in input().split()]
m-=1
a=[int(i) for i in input().split()]
ans=1000000
for i in range(n):
    if a[i]!=0 and a[i]<=k:
        ans=min(ans,abs(i-m))
print(ans*10)

n, m, k = list(map(int, input().split()))

a = list(map(int, input().split()))
b = []
for i in range(len(a)):
    if a[i] != 0 and a[i] <= k:
        b.append(abs(i + 1 - m))
print(min(b) * 10)



n, m, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n):
    if a[i] != 0 and a[i] <= k:
        ans = min(ans, abs(i - (m - 1)) * 10)
        
print(ans)

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 10 ** 13
m -= 1
for i in range(n):
    if a[i] != 0 and a[i] <= k and ans > abs(i - m) * 10:
        ans = 10 * abs(i - m)
print(ans)

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
r = 10000
for i in range(n):
    if a[i] <= k and a[i] != 0:
        r = min(r, abs(m-i-1))
print(r*10)


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
mn = 10 ** 9
for i in range(n):
	if i != m - 1 and a[i] <= k and a[i] != 0:
		mn = min(mn, abs(m - i - 1) * 10)
print(mn)

n, m, k = [int(x) for x in input().split()]
costs = [int(x) for x in input().split()]
ans = 10000000000
m = m-1
for index, cost in enumerate(costs):
    if cost != 0 and cost <= k:
        ans = min(ans, abs(m-index))
print(ans*10)


import heapq
from collections import deque
import sys

#
# f = open('input.txt')
# sys.stdin = f


n,m,k=map(int,input().split())
m-=1
s=list(map(int,input().split()))
d = n*2
for i in range(n):
    if s[i] and s[i]<=k:
        tmp=abs(i-m)
        if tmp<d:
            d=tmp
print(d*10)

n, m, k = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
ans = 10000000000
for i in range(n):
    if s[i] <= k and s[i]:
        ans = min( ans, 10* abs(m-1-i))

print(ans)

n, m, k = [ int(x) for x in input().split() ]
a = [ int(x) for x in input().split() ]

m -= 1

r = 1000000

for i, x in enumerate(a):
    if 0 < x <= k:
        r = min(r, abs(i - m) * 10)

print(r)


from sys import stdin, stdout

n, m, k = map(int, stdin.readline().split())
challengers = list(map(int, stdin.readline().split()))
m -= 1

i = 1
ans = 10
while True:
    if m + i < n and challengers[m + i] and challengers[m + i] <= k:
        break
    
    if m - i >= 0 and challengers[m - i] and challengers[m - i] <= k:
        break
    
    ans += 10
    i += 1


stdout.write(str(ans))

n, m, k = map(int, input().split())

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

m -= 1

ml = mr = 10000000000

for i in range(m + 1, n):
    if a[i] != 0 and a[i] <= k:
        mr = i
        break

for i in range(m - 1, -1, -1):
    if a[i] != 0 and a[i] <= k:
        ml = i
        break

print(min(abs(m - ml), abs(m - mr)) * 10)

import sys

def solve():
    n, m, k = map(int, input().split())
    m = m - 1
    a = [int(i) for i in input().split()]

    min_d = 10**9

    for i in range(n):
        if 0 < a[i] <= k:
            min_d = min(min_d, abs((m - i)) * 10)

    ans = min_d
    print(ans)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def __starting_point():
    solve()
__starting_point()

#!/bin/python3

import sys
n, m , k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = n ;
for i in range(n):
    if a[i] != 0 and a[i] <= k and ans > abs(m - i - 1):
        ans = abs(m - i - 1)
print(ans*10)


n,m,k=map(int,input().split())
l=list(map(int,input().split()))
ans=11**11
for i in range(n):
    if i==m-1 or l[i]>k or l[i]==0: continue
    if abs(m-1-i)<ans: ans=abs(m-1-i)
print(ans*10)

n,m,k = list(map(int, input().split()))
a = list(map(int, input().split()))
m -= 1
ans = 1000
for i in range(m, -1 , -1):
    if a[i] and a[i] <= k:
        ans = m - i
        break
for i in range(m, n):
    if a[i] and a[i] <= k:
        ans = min(ans, i - m)
        break
print(ans * 10)


n, m, k = list(map(int, input().split()))
m -= 1
print(10 * min(abs(i - m) for i, c in enumerate(map(int, input().split())) if 0 < c <= k))


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
m-=1
be = -1
af = n + 1
for i in range(n):
	if a[i] <= k and a[i] != 0 and i < m and i > be:
		be = i
	elif a[i] <= k and a[i] != 0 and i > m and i < af:
		af = i
if be == -1:
	print((af-m)*10)
elif af == n+1:
	print((m-be)*10)
else:
	print(10*min(m-be, af-m))

n, m, k = map(int, input().split())
data = map(int, input().split())
temp = [abs(m-1-i) for i, v in enumerate(data) if v and v <= k]
res = min(temp)
print(res*10)

n, m, k = map(int, input().split())
dist = 1e10
a = [int(i) for i in input().split()]
for i in range(n):
    if a[i] > 0 and a[i] <= k:
        dist = min(dist, abs(m - 1 - i))
print(dist * 10)

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))

min_dist = n + 1
m -= 1

for i in range(len(a)):
    if a[i] > 0 and a[i] <= k:
        min_dist = min(min_dist, abs(i - m))

print(min_dist * 10)


n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))

m-=1


min_dist = n+1
min_index = -1
for i in range(len(A)):
    if A[i] != 0 and A[i] <= k and abs(i-m) <= min_dist:
        min_index = i
        min_dist = abs(i-m)


print(min_dist*10)



n, m, k = list(map(int, input().split()))

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

m=m-1
lp=m-1
rp=m+1
found=False
ansr=10000000
if rp<n:
    while not found and rp<n:
        if l[rp]!=0 and l[rp]<=k:
            ansr=rp-m
            found = True
        rp+=1
    found = False
else:
    ansr=100000
ansl=1000000
if lp>=0:
    while not found and lp>=0:
        if l[lp]!=0 and l[lp]<=k:
            ansl=m-lp
            found = True
        lp-=1
else:
    ansl=100000
print(min(ansr, ansl)*10)