#include #define int long long using namespace std; const int N=4e5+10,M=20,INF=0x3f3f3f3f,mod=998244353; int n,k,a[N],nxt[M][N]; namespace Fast_IO { static char buf[1000000],*paa=buf,*pd=buf,out[10000000];int length=0; #define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++ inline int read() { int x(0),t(1);char fc(getchar()); while(!isdigit(fc)){if(fc=='-') t=-1;fc=getchar();} while(isdigit(fc)) x=(x<<1)+(x<<3)+(fc^48),fc=getchar(); return x*t; } inline void flush(){fwrite(out,1,length,stdout);length=0;} inline void put(char c){if(length==9999999) flush();out[length++]=c;} inline void put(string s){for(char c:s) put(c);} inline void print(int x) { if(x<0) put('-'),x=-x; if(x>9) print(x/10); put(x%10+'0'); } inline bool chk(char c) { return !(c>='a'&&c<='z'||c>='A'&&c<='Z'||c>='0'&&c<='9'||c=='.'||c=='#'); } inline bool ck(char c) { return c!='\n'&&c!='\r'&&c!=-1&&c!=' '; } inline void rd(char s[],int&n) { s[++n]=getchar(); while(chk(s[n])) s[n]=getchar(); while(ck(s[n])) s[++n]=getchar(); n--; } } using namespace Fast_IO; inline bool check(int x) { for(int i=0;i<=2*n;i++) nxt[0][i]=lower_bound(a+1,a+1+(2*n),a[i]+x)-a; for(int k=0;k>l)&1) j=nxt[l][j]; if(j-i<=n) return true; }return false; } inline void solve() { n=read(),k=read();for(int i=1;i<=n;i++) a[i+n]=a[i]=read(); for(int i=1;i<=n<<1;i++) a[i]+=a[i-1];int l=0,r=INF,ans=0; while(l<=r) { int mid=(l+r)>>1; if(check(mid)) ans=mid,l=mid+1; else r=mid-1; }print(ans); } signed main() { int T=1;while(T--) solve(); genshin:;flush();return 0; }