#include using namespace std; #define INF 1000000007 #define LINF (1LL << 62) typedef long long i64; typedef pair P; inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; } templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n >> k; for(int i = 0; i < n; i++){ cin >> a[i]; } k--; if(a[k] == 0){ cout << 0 << endl; return; } i64 l = 0, r = 0; for(int i = k-1; i >= 0; i--){ if(a[i] == 0) break; l += a[i]; if(a[i] == 1) break; } for(int i = k+1; i < n; i++){ if(a[i] == 0) break; r += a[i]; if(a[i] == 1) break; } if(a[k] == 1){ cout << 1+max(l,r) << endl; } else{ cout << a[k]+l+r << endl; } } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); int t = 1; //cin >> t; while(t--){ solve(); } return 0; }