题目链接:http://codeforces.com/problemset/problem/680/B
//简单的模拟
#include<stdio.h>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<functional>
#include<vector>
#include<iomanip>
#include<math.h>
#include<iostream>
#include<sstream>
#include<set>
#include<climits>
#include<map>
#include<bitset>
using namespace std;
int main()
{
cin.sync_with_stdio(false);
int n,a,A[105]={0};
cin>>n>>a;
for (int i=1;i<=n;i++)
cin>>A[i];
int Ans=0,x=0,l,r;
while (a+x<=n&&a-x>=1)
{
l=a-x,r=a+x;
if (l==r)
Ans+=A[l];
else if (A[l]+A[r]==2)
Ans+=2;
x++;
}
if (l==1&&r==n)
Ans=Ans;
else if (l==1)
{
r++;
while (r<=n)
{
Ans+=A[r];
r++;
}
}
else if (r==n)
{
l--;
while (l>=1)
{
Ans+=A[l];
l--;
}
}
cout<<Ans;
return 0;
}