#include #define rep(i,n) for(int i=0;i P; const ll INF = 1e12; const int MOD = 1000000007; int main() { int n,k; cin >> n >> k; --k; vector a(n); rep(i,n) cin >> a[i]; if(a[k] == 0) { cout << 0 << endl;} else if(a[k] == 1){ ll res1 = 0,res2 = 0; for(int i = k; i >= 0;i--){ res1 += a[i]; if(a[i] == 1 && i != k) break; } for(int i = k;i < n;i++){ res2 += a[i]; if(a[i] == 1 && i != k) break; } cout << max(res1,res2) << endl; } else{ ll res = 0; int l = 0,r = n-1; for(int i = k;i>=0;i--){ if(a[i] == 1) l = i; } for(int i = k;i