1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <algorithm>
5 #define inf 233333333;
6 using namespace std;
7 int n,k;
8 long long a[100001];
9 long long l,r,ans_l,ans_r,mid;
10 int i;
11 long long cnt=0;
12 long long num,maxn;
13 long long check(long long x)
14 {
15 int i;
16 long long sum=0;
17 long long num=0;
18 for (i=1;i<=n;i++) {
19 sum+=a[i];
20 if (sum<0) sum=0;
21 else {
22 if (sum>=x) {
23 num++;
24 sum=0;
25 }
26 }
27 }
28 return num;
29 }
30 int main()
31 {
32 scanf("%d%d",&n,&k);
33 for (i=1;i<=n;i++) {
34 scanf("%lld",&a[i]);
35 if (a[i]>0) num+=a[i];
36 }
37 maxn=num;
38 l=1; r=maxn;
39 while (l<=r) {
40 mid=(l+r)>>1;
41 //cout<<mid<<endl;
42 if (check(mid)>k) l=mid+1;
43 else r=mid-1;
44 }
45 ans_l=l;
46 l=1; r=maxn;
47 while (l<=r) {
48 mid=(l+r)>>1;
49 //cout<<mid<<endl;
50 if (check(mid)<k) r=mid-1;
51 else l=mid+1;
52 }
53 ans_r=r;
54 if (check(ans_l)!=k||check(ans_r)!=k) printf("%d",-1);
55 else printf("%lld %lld",ans_l,ans_r);
56 }