There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.

Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he knows that there is at most one criminal in each city.

Limak is going to use a BCD (Bear Criminal Detector). The BCD will tell Limak how many criminals there are for every distance from a city a. After that, Limak can catch a criminal in each city for which he is sure that there must be a criminal.

You know in which cities criminals are. Count the number of criminals Limak will catch, after he uses the BCD.


-----Input-----

The first line of the input contains two integers n and a (1 ≤ a ≤ n ≤ 100) — the number of cities and the index of city where Limak lives.

The second line contains n integers t_1, t_2, ..., t_{n} (0 ≤ t_{i} ≤ 1). There are t_{i} criminals in the i-th city.


-----Output-----

Print the number of criminals Limak will catch.


-----Examples-----
Input
6 3
1 1 1 0 1 0

Output
3

Input
5 2
0 0 0 1 0

Output
1



-----Note-----

In the first sample, there are six cities and Limak lives in the third one (blue arrow below). Criminals are in cities marked red.

 [Image] 

Using the BCD gives Limak the following information:

  There is one criminal at distance 0 from the third city — Limak is sure that this criminal is exactly in the third city.  There is one criminal at distance 1 from the third city — Limak doesn't know if a criminal is in the second or fourth city.  There are two criminals at distance 2 from the third city — Limak is sure that there is one criminal in the first city and one in the fifth city.  There are zero criminals for every greater distance. 

So, Limak will catch criminals in cities 1, 3 and 5, that is 3 criminals in total.

In the second sample (drawing below), the BCD gives Limak the information that there is one criminal at distance 2 from Limak's city. There is only one city at distance 2 so Limak is sure where a criminal is.

 [Image]

Difficulty: interview

Starter code:

Solutions:
n, a = list(map(int, input().split()))
x = list(map(int, input().split()))

a -= 1

result = x[a]

for i in range(1, n + 1):
    le = a - i
    rg = a + i

    le_i = le >= 0 and le < n
    rg_i = rg >= 0 and rg < n
    if not le_i and not rg_i:
        break

    if le_i and not rg_i:
        result += x[le]
    elif not le_i and rg_i:
        result += x[rg]
    else:
        if x[le] == x[rg] == 1:
            result += 2

print(result)


n, a = map(int, input().split())
t = list(map(int, input().split()))
a -= 1
d = [0] * n
for i in range(n):
    if t[i] == 1:
        d[abs(i - a)] += 1

res = 0
i1 = i2 = a
for i in range(n):
    if d[i] == 2:
        res += 2
    elif d[i] == 1 and (i1 < 0 or i2 >= n or i1 == i2):
        res += 1
    i1 -= 1
    i2 += 1
print(res)

n, a = list(map(int, input().split()))
arr = list(map(int, input().split()))
a -= 1
l = a
r = a
ans = 0
while l >= 0 or r < n:
    if l < 0:
        if arr[r]:
            ans += 1
    elif r >= n:
        if arr[l]:
            ans += 1
    elif l == r and arr[l] == 1:
        ans += 1
    elif arr[l] == 1 and arr[r] == 1:
        ans += 2
    l -= 1
    r += 1
print(ans)


read = lambda: list(map(int, input().split()))
n, a = read()
t = list(read())
ans = 0
for d in range(n):
    i, j = a - d - 1, a + d - 1
    if i == j: ans += t[i]
    elif i >= 0 and j < n and t[i] == t[j]: ans += t[i] + t[j]
    elif i < 0 and j < n: ans += t[j]
    elif i >= 0 and j >= n: ans += t[i]
print(ans)


import sys,math
n,m=map(int,input().split())
m-=1
z=list(map(int,input().split()))
a=m
b=m
ans=0
while a<n or b>=0:
    if a<n and b>=0 and a!=b:
        if z[a]==1 and z[b]==1:
            ans+=2
    elif a==b:
        if z[a]==1:
            ans+=1
    elif b>=0:
        if z[b]==1:
            ans+=1
    else:
        if z[a]==1:
            ans+=1
    a+=1
    b-=1
print(ans)

n, p = map(int, input().split())
p -= 1
a = list(map(int, input().split()))

res = a[p]
for i in range(1, len(a)):
	if p - i < 0 and p + i >= len(a):
		break

	if p - i < 0:
		res += a[p + i]
	elif p + i >= len(a):
		res += a[p - i]
	elif a[p + i] + a[p - i] == 2:
		res += 2
print(res)

[n, a], c = list(map(int, input().split())), [0] + list(map(int, input().split()))
ans = 0
for d in range(max(a, n - a + 1)):
    directions = found = 0
    if a - d > 0:
        directions += 1
        found += c[a - d]
    if a + d <= n and d:
        directions += 1
        found += c[a + d]
    ans += (directions == found) * found
print(ans)


def in_bounds(x, n):
    return 0 <= x < n

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

a -= 1
ans = t[a]
for d in range(1, n):
    l = a - d
    r = a + d

    if in_bounds(l, n) and in_bounds(r, n) and t[l] == 1 and t[r] == 1:
        ans += 2
    elif not in_bounds(l, n) and in_bounds(r, n) and t[r] == 1:
        ans += 1
    elif in_bounds(l, n) and not in_bounds(r, n) and t[l] == 1:
        ans += 1

print(ans)


n, a = list(map(int, input().split()))
s = list(map(int, input().split()))
a -= 1
if s[a] == 1:
    ans = -1
else:
    ans = 0
for i in range(n):
    p1 = a - i
    p2 = a + i
    if p1 >= 0 and s[p1] == 1:
        c = 1
    else:
        c = 0
    if p2 < n and s[p2] == 1:
        c += 1
    if c == 2:
        ans += 2
    elif (c == 1 and p1 < 0) or (c == 1 and p2 >= n):
        ans += 1
print(ans)


n, a = map(int, input().split())
a -= 1
t = list(map(int, input().split()))
ans = t[a]
for d in range(1, n):
    if a >= d and a + d < n and t[a - d] and t[a + d]:
        ans += 2
    elif a < d and a + d < n and t[a + d]:
        ans += 1
    elif a >= d and a + d >= n and t[a - d]:
        ans += 1
print(ans)

n, a = list(map(int, input().split()))
v = list(map(int, input().split()))
a -= 1
it = 0
cnt = 0
while (a - it >= 0) and (a + it < n):
	x = v[a - it] + v[a + it] 
	if it == 0:
		if x == 2:
			cnt += 1
	elif x == 1:
		if it == 0:
			cnt += 1
	elif x == 2:
		cnt += 2
	it += 1

while (a - it >= 0) or (a + it < n):
	if a - it >= 0:
		cnt += v[a - it]
	if a + it < n:
		cnt += v[a + it]
	it += 1

print(cnt)





import sys

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

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

i, j = a - 1, a - 1

c = 0

if arr[i]:
    c += 1

while i >= 0 or j < n:
    i -= 1
    j += 1
    if i >= 0 and j < n and arr[i] == arr[j] == 1:
        c += 2
    elif i >= 0 and j >= n and arr[i]:
        c += 1
    elif i < 0 and j < n and arr[j]:
        c += 1

print(c)
sys.stdout.flush()


n, a = map(int, input().split())
t = list(map(int, input().split()))
cnt = [0 for i in range(101)]
crime = [0 for i in range(101)]
for i in range(1, n + 1):
    d = abs(a - i)
    cnt[d] += 1
    crime[d] += t[i - 1]
ans = 0
for i in range(101):
    if crime[i] == cnt[i]:
        ans += crime[i]
print(ans)

from collections import defaultdict,deque,Counter,OrderedDict
import sys
sys.setrecursionlimit(20000)
def main():
    n,he = map(int,input().split())
    he -= 1
    l = [int(i) for i in input().split()]
    ans = l[he]
    for i in range(1,100):
        tor = he + i
        tol = he - i
        if tor < n and tol >= 0:
            if l[tor] == 1 and l[tol] == 1:
                ans += 2
        elif tor < n:
            if l[tor] == 1:
                ans += 1
        elif tol >= 0:
            if l[tol] == 1:
                ans += 1
    print(ans)





def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3

n, l = (int(i) for i in input().split())
n_criminals = [int(i) for i in input().split()]
total = 0

for i in range(101):
    cities = set([l + i, l - i])
    cities = { c for c in cities if c > 0 and c <= n }
    criminals = sum(n_criminals[c-1] for c in cities)

    if criminals == len(cities):
        total += criminals

print(total)


__author__ = 'Utena'
n,a=map(int,input().split())
cities=[0]+list(map(int,input().split()))
p=[0]*n
c=[0]*n
for i in range(n):
    if i==0:p[i]=1
    elif i<=min(n-a,a-1):p[i]=2
    elif min(n-a,a-1)<i<=max(n-a,a-1):p[i]=1
    else:p[i]=0
for i in range(1,n+1):
    c[abs(a-i)]+=cities[i]
t=0
for i in range(n):
    if c[i]==p[i]:
        t+=c[i]
print(t)

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

t = [0] + [int(x) for x in input().split(' ')]

m = min(n-a, a-1)

res = 0

if t[a] == 1:
	res += 1
	t[a] = 0

for i in range(1,m+1):
	s = t[a+i] + t[a-i]
	if s == 2: res += 2
	t[a+i],t[a-i] = 0, 0
	
print(res + sum(t))

n, a = map(int, input().split())
a -= 1
criminal = list(map(int, input().split()))
l = []
r = []

r = criminal[a + 1:]
l = criminal[:a][::-1]

ans = 0

if criminal[a] == 1:
    ans += 1

s = min(len(r), len(l))
for i in range(s):
    if l[i] == r[i]:
        ans += 2 * l[i]

if len(r) > len(l):
    ans += sum(r[s:])
elif len(l) > len(r):
    ans += sum(l[s:])

print(ans)

n, a = map(int, input().split())
criminals = list(map(int, input().split()))
i = j = a - 1
amount = 0
while i >= 0 and j < n:
    if criminals[i] == criminals[j] == 1:
        amount += 1 if i == j else 2
    i -= 1
    j += 1
while i >= 0:
    amount += criminals[i]
    i -= 1
while j < n:
    amount += criminals[j]
    j += 1
print(amount)

n,a = (int(i) for i in input().split())
l =list(map(int,input().split()))
a-=1
ans = 0
for d in range(n):
    if d == 0 and l[a] == 1:
        ans+=1
    elif a-d>=0 and a+d<n and l[a-d] == 1 and l[a+d] == 1:
        ans+=2
    elif a-d < 0 and a+d<n and l[a+d] == 1:
        ans+=1
    elif a-d>=0 and a+d >= n and l[a-d] == 1:
        ans+=1
        
print(ans)


n, a = list(map(int, input().split()))
a -= 1
t = list(map(int, input().split()))
ans = 0
R = list(range(0, n))
for dis in range(0, 100):
    l = a - dis
    r = a + dis
    if l not in R and r not in R:
        break
    elif l in R and r not in R:
        ans += t[l]
    elif l not in R and r in R:
        ans += t[r]
    elif t[l] == 1 and t[r] == 1:
        ans += 2 if l != r else 1
print(ans)


n, a = list(map(int,input().split()))
c = list(map(int,input().split()))
res = c[a-1]
for i in range(1, max(n-a+1,a)):
    l, r = a - 1 - i, a - 1 + i
    if l >= 0 and r < n:
        if c[l] and c[r]:
            res += 2
    elif l >= 0:
        if c[l]:
            res += 1
    elif r < n:
        if c[r]:
            res += 1
print(res)


[n,a] = list(map(int, input().split(" ")))
t = list(map(int, input().split(" ")))

m1 = min(n-a, a-1) # t==2 then can catch for m1>=d>=1

s = t[a-1]

for i in range(1,m1+1):
	if t[a-1-i] + t[a-1+i] == 2:
		s += 2

for i in range(n):
	if abs(a-1-i) <= m1:
		continue
	s += t[i]


print(s)


n, a = map(int, input().split())
arr = list(map(int, input().split()))
a -= 1
ans = 0
for i in range(n):
	# print(i, ans, 2 * a - i)
	if (i == a):
		ans += arr[i]
	elif (i < a):
		j = 2 * a - i
		if (j >= n or arr[j] == 1):
			ans += arr[i]
	else:
		j = 2 * a - i
		if (j < 0 or arr[j] == 1):
			ans += arr[i]
print(ans)

n,a=map(int,input().split())
t=[0]+list(map(int,input().split()))
ans=t[a]
for i in range(1,max(a,n-a+1)):
   if a-i>0 and a+i<=n:
      if t[a-i]==t[a+i]: ans+=t[a-i]+t[a+i]
   elif a-i>0: ans+=t[a-i]
   else: ans+=t[a+i]
    
print(ans)