#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, i, j, arr[300] = {0}, p = 0, k = 0, c, d;     cin >> n >> a;     for (i = 1; i < n + 1; i++) {       cin >> arr[i];     }     arr[0] = 1, arr[n + 1] = 1;     j = min(a, n - a + 1);     for (i = j; i < n + 1; i++) {       c = a + k;       d = a - k;       if (d < 1) d = 0;       if (c > n) c = n + 1;       if (arr[d] == arr[c] and arr[c]) {         if (c != d and c <= n and d > 0)           p += 2;         else           p++;       }       k++;     }     cout << p << endl;     return 0;   }   