#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    mego
    ll n,k,x,y,l=0,r=0,c=0,mx=0,l1=0,idx=0;
    vector<ll> v,vsum;
    vector<ll> vp;
   map<int,ll> ma;
    cin>>n>>k;
    loop(i,0,n)
    {
        cin>>x;
        c+=x;
        v.pb(x);
        vsum.pb(c);
    }
loop(i,0,n)
if(i+k-1 <n)
{
    x=vsum[i+k-1];
    if(i>0)
        x-=vsum[i-1];
    vp.pb(x);
//    cout<<i+1<<" "<<x<<endl;
}
c=0;
for(int i=vp.size()-1;i>=0;i--)
{
    if(vp[i] >=mx)
    {
        mx=vp[i];
        idx=i;
    }
    ma[i]=idx;
}
mx=0;
loop(i,0,vp.size())
if(i+k <vp.size() ){
   //cout<<i<<" "<<i+k<<" "<<ma[i+k]<<" "<<vp[i]<<" "<<vp[ma[i+k]]<<endl;
    c=vp[i]+vp[ma[i+k]];
    if(c>mx)
    {mx=c;
        l=i;
        l1=(ma[i+k]);
    }
    else if(c==mx)
    {
        l=min(l,(ll)i);
        l1=min(l1,(ma[i+k]));

    }
}
cout<<l+1<<" "<<l1+1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    mego
    ll n,k,x,y,l=0,r=0,c=0,mx=0,l1=0,idx=0;
    vector<ll> v,vsum,vp;
   map<int,ll> ma;
    cin>>n>>k;
    loop(i,0,n)
    {
        cin>>x;
        c+=x;
        v.pb(x);
        vsum.pb(c);
    }
loop(i,0,n)
if(i+k-1 <n)
{
    x=vsum[i+k-1];
    if(i>0)
        x-=vsum[i-1];
    vp.pb(x);
}
c=0;
for(int i=vp.size()-1;i>=0;i--)
{
    if(vp[i] >=mx)
    {
        mx=vp[i];
        idx=i;
    }
    ma[i]=idx;
}
mx=0;
loop(i,0,vp.size())
if(i+k <vp.size() ){
    c=vp[i]+vp[ma[i+k]];
    if(c>mx)
    {mx=c;
        l=i;
        l1=(ma[i+k]);
    }
    else if(c==mx)
    {
        l=min(l,(ll)i);
        l1=min(l1,(ma[i+k]));

    }
}
cout<<l+1<<" "<<l1+1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    mego
    int n,k,x,l=0,r=0,c=0;
    vector<int> v,vsum;
    vsum.pb(0);
    cin>>n>>k;
    loop(i,0,n)
    {
        cin>>x;
        c+=x;
        v.pb(x);
        vsum.pb(c);
    }

    loop(i,0,n)
    if((i>=k || n-i>= 2*k)&& (i+k-1 <n))
    {
        if(vsum[i+k]-vsum[i] > (vsum[r]-vsum[l]))
        {
            l=i;
            r=i+k;
        }

    }
    int l1=0,r1=0;
    loop(i,0,n)
    if((i+k <(l+1) || i>(r-1) )&& (i+k-1 <n))
    {//cout<<i<<" "<<k<<" "<<vsum[i+k]<<" "<<vsum[i]<<" "<<vsum[r1]<<" "<<vsum[l1]<<endl;
        if(vsum[i+k]-vsum[i] > (vsum[r1]-vsum[l1]))
        {
            l1=i;
            r1=i+k;
        }

    }
    if(l>l1)
        swap(l,l1);
cout<<l+1<<" "<<l1+1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    mego
    ll n,k,x,l=0,r=0,c=0;
    vector<ll> v,vsum;
    vsum.pb(0);
    cin>>n>>k;
    loop(i,0,n)
    {
        cin>>x;
        c+=x;
        v.pb(x);
        vsum.pb(c);
    }

    loop(i,0,n)
    if((i>=k || n-i>= 2*k)&& (i+k-1 <n))
    {
        if(vsum[i+k]-vsum[i] > (vsum[r]-vsum[l]))
        {
            l=i;
            r=i+k;
        }

    }
    ll l1=0,r1=0;
    loop(i,0,n)
    if((i+k <(l+1) || i>(r-1) )&& (i+k-1 <n))
    {//cout<<i<<" "<<k<<" "<<vsum[i+k]<<" "<<vsum[i]<<" "<<vsum[r1]<<" "<<vsum[l1]<<endl;
        if(vsum[i+k]-vsum[i] > (vsum[r1]-vsum[l1]))
        {
            l1=i;
            r1=i+k;
        }

    }
    if(l>l1)
        swap(l,l1);
cout<<l+1<<" "<<l1+1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define READ(FILE) freopen(FILE,"r",stdin)
#define WRITE(FILE) freopen(FILE,"w",stdout)
#define loop(i,s,e) for(int i=s;i<e;i++)
#define mego fast();
using namespace std;
void fast()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    mego
    int n,k,x,l=0,r=0,c=0;
    vector<int> v,vsum;
    vsum.pb(0);
    cin>>n>>k;
    loop(i,0,n)
    {
        cin>>x;
        c+=x;
        v.pb(x);
        vsum.pb(c);
    }

    loop(i,0,n)
    if((i>=k || n-i>= 2*k)&& (i+k-1 <n))
    {
        if(vsum[i+k]-vsum[i] > (vsum[r]-vsum[l]))
        {
            l=i;
            r=i+k;
        }

    }
    int l1=0,r1=0;
    loop(i,0,n)
    if((i+k-1 <(l+1) || i>(r-1) )&& (i+k-1 <n))
    {//cout<<i<<" "<<k<<" "<<vsum[i+k]<<" "<<vsum[i]<<" "<<vsum[r1]<<" "<<vsum[l1]<<endl;
        if(vsum[i+k]-vsum[i] > (vsum[r1]-vsum[l1]))
        {
            l1=i;
            r1=i+k;
        }

    }
cout<<l+1<<" "<<l1+1;
    return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long int
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*K-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

signed main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*k-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long int
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*K-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;

#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

signed main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*k-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long int
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

signed main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*k-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long int
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

ll fact(ll n)
{
    ll res=1;
    for(ll i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*K-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<utility>
using namespace std;
#define int long long
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n-1;i>=0;i--)
long long mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//to find nth fibonacci number.
//This code returns Fn and Fn+1 as a pair.
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

int fact(int n)
{
    int res=1;
    for(int i=n;i>=1;i--)
        (res*=i)%=mod;
    return (res%mod);

}

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

bool isPrime(long long n)
{

    if (n <= 1)
        return false;

    for (long long i = 2; i <= sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}

//THIS IS THE CODE TO FIND ALL PRIME NUMBERS IN THE RANGE "L" to "R";

vector<long long > segmentedSieve(long long L, long long R) {
    // generate all primes up to sqrt(R)
    long long lim = sqrt(R);
    vector<bool> mark(lim + 1, false);
    vector<long long> primes;
    for (long long i = 2; i <= lim; ++i) {
        if (!mark[i]) {
            primes.emplace_back(i);
            for (long long j = i * i; j <= lim; j += i)
                mark[j] = true;
        }
    }

    vector<bool> isPrime(R - L + 1, true);
    for (long long i : primes)
        for (long long j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;
    if (L == 1)
        isPrime[0] = false;
    vector<long long >realprime;
   for(int i=0;i<=R-L;i++){
      if(isPrime[i]){
         realprime.emplace_back(i+L);

      }
   }
    return realprime;

}

bool isPalindrome(string s)
{

    int l = 0;
    int h = s.size()-1;

    while (h > l)
    {
        if (s[l++] != s[h--])
        {

            return false;
        }
    }
   return true;
}

int ternarySearch(int l, int r, int key, int ar[])

{
    while (r >= l) {

        // Find the mid1 and mid2
        int mid1 = l + (r - l) / 3;
        int mid2 = r - (r - l) / 3;

        // Check if key is present at any mid
        if (ar[mid1] == key) {
            return mid1;
        }
        if (ar[mid2] == key) {
            return mid2;
        }

        // Since key is not present at mid,
        // check in which region it is present
        // then repeat the Search operation
        // in that region

        if (key < ar[mid1]) {

            // The key lies in between l and mid1
            r = mid1 - 1;
        }
        else if (key > ar[mid2]) {

            // The key lies in between mid2 and r
            l = mid2 + 1;
        }
        else {

            // The key lies in between mid1 and mid2
            l = mid1 + 1;
            r = mid2 - 1;
        }
    }

    // Key not found
    return -1;
}

  int binarySearch(int arr[], int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;

        // Check if x is present at mid
        if (arr[m] == x)
            return m;

        // If x greater, ignore left half
        if (arr[m] < x)
            l = m + 1;

        // If x is smaller, ignore right half
        else
            r = m - 1;
    }

    // if we reach here, then element was
    // not present
    return -1;
}

//"KADANE'S ALGORITHM"
//iski time complexity o(n) hn i.e the smallest possible
long long maxsubarraysum(long long *array,long long n){
   long long best = 0, sum = 0;
for (long long  k = 0; k < n; k++) {
sum = max(array[k],sum+array[k]);
best = max(best,sum);
}
return  best ;

}
//to add two very large numbers

string findSum(string str1, string str2)
{
	if (str1.length() > str2.length())
		swap(str1, str2);
	string str = "";
	int n1 = str1.length(), n2 = str2.length();

	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i=0; i<n1; i++)
	{

		int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');

		carry = sum/10;
	}
	for (int i=n1; i<n2; i++)
	{
		int sum = ((str2[i]-'0')+carry);
		str.push_back(sum%10 + '0');
		carry = sum/10;
	}
	if (carry)
		str.push_back(carry+'0');
	reverse(str.begin(), str.end());
	return str;
}

string smin(string a,string b)
{

if(a.size()<b.size())return a;
if(a.size()>b.size())return b;
if(a<=b)return a;
else return b;
}

  bool so(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}

int getsum(const vector<int>&s,int l,int r){
   return (l==0)?s[r]:(s[r]-s[l-1]);
}

int main(){
ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vector<int>a(n),s(n);
cin>>a[0];
s[0]=a[0];
for(int i=1;i<n;i++){
   cin>>a[i];
   s[i]=s[i-1]+a[i];

}
pair<int,int>ans={n-2*k,n-k};
int sum=getsum(s,n-2*k,n-k-1)+getsum(s,n-k,n-1);
pair<int,int> suff={n-k,getsum(s,n-k,n-1)};
for(int i=n-2*k-1;i>=0;i--){
   int cur=getsum(s,i+k,i+2*k-1);
   if(cur>=suff.second){
      suff={i+k,cur};
   }
   cur=getsum(s,i,i+k-1)+suff.second;
   if(cur>=sum){
      sum=cur;
      ans={i,suff.first};

   }
}
cout<<ans.first+1<<" "<<ans.second+1;
return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    int ans;
    int start;
}v[1000*1000];

bool compare(q a,q b)
{
    return a.ans>b.ans;
}

void logic()
{
    int n,k;
    cin>>n>>k;
    int arr[n+1]={0};
    int brr[n+1]={0};
    for(int i=1;i<=n;++i)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }
    for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int index=0;
    //debug(n);
    for(int i=k;i<=n;++i)
    {
        v[index].ans=arr[i]-arr[i-k];
        v[index].start=i-k+1;
        index++;
    }
    sort(v,v+index,compare);
    int count=0;
    vector<int> finalans;
    map<int,int> m;
    for(int i=0;i<index;++i)
    {
        if(i==0)
        {
            finalans.push_back(v[i].start);
            for(int j=v[i].start;j<v[i].start+k;++j)
            {
                m[j]=1;
            }
        }
        else
        {
            if(m[v[i].start]==1) continue;
            else
            {
                finalans.push_back(v[i].start);
                break;
            }
        }
        //debugmp(m);
    }
    sort(finalans.begin(),finalans.end());
    for(int i=0;i<2;++i)
    {
        cout<<finalans[i]<<" ";
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    /*for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int dp[n+1][3];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];*/
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    int ans;
    int start;
}v[1000*1000];

bool compare(q a,q b)
{
    return a.ans>b.ans;
}

void logic()
{
    int n,k;
    cin>>n>>k;
    int arr[n+1]={0};
    int brr[n+1]={0};
    for(int i=1;i<=n;++i)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }
    for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int index=0;
    //debug(n);
    for(int i=k;i<=n;++i)
    {
        v[index].ans=arr[i]-arr[i-k];
        v[index].start=i-k+1;
        index++;
    }
    sort(v,v+index,compare);
    int count=0;
    vector<int> finalans;
    map<int,int> m;
    for(int i=0;i<index;++i)
    {
        if(i==0)
        {
            finalans.push_back(v[i].start);
            for(int j=v[i].start;j<v[i].start+k;++j)
            {
                m[j]=1;
            }
        }
        else
        {
            bool flag=0;
            for(int j=v[i].start;j<v[i].start+k;++j)
            {
                if(m[j]==1)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1) continue;
            else
            {
                finalans.push_back(v[i].start);
                break;
            }
        }
        //debugmp(m);
    }
    sort(finalans.begin(),finalans.end());
    for(int i=0;i<2;++i)
    {
        cout<<finalans[i]<<" ";
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    /*for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int dp[n+1][3];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];*/
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    if(a.ans!=b.ans) return a.ans>b.ans;
    else return a.start<b.start;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long dp[n+1][3];
    for(long long i=0;i<=n;++i)
    {
        for(long long j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    long long val=dp[n][2];
    vector<long long> values;
    long long m=2;
    for(long long i=n;i>=0;--i)
    {
        if(val==dp[i-1][m]) continue;
        else
        {
            values.push_back(i-k);
            val=dp[i-k][m-1];
            m--;
            if(m==0) break;
        }
    }
    sort(values.begin(),values.end());
    for(long long i=0;i<values.size();++i)
    {
        cout<<values[i]+1<<" ";
    }
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    return a.ans>b.ans;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    long long brr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long index=0;
    //debug(n);
    for(long long i=k;i<=n;++i)
    {
        v[index].ans=arr[i]-arr[i-k];
        v[index].start=i-k+1;
        index++;
    }
    sort(v,v+index,compare);
    long long count=0;
    vector<long long> finalans;
    map<long long,long long> m;
    for(long long i=0;i<index;++i)
    {
        if(i==0)
        {
            finalans.push_back(v[i].start);
            for(long long j=v[i].start;j<v[i].start+k;++j)
            {
                m[j]=1;
            }
        }
        else
        {
            bool flag=0;
            for(long long j=v[i].start;j<v[i].start+k;++j)
            {
                if(m[j]==1)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1) continue;
            else
            {
                finalans.push_back(v[i].start);
                break;
            }
        }
        //debugmp(m);
    }
    sort(finalans.begin(),finalans.end());
    for(long long i=0;i<2;++i)
    {
        cout<<finalans[i]<<" ";
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    /*for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int dp[n+1][3];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];*/
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    if(a.ans!=b.ans) return a.ans>b.ans;
    else return a.start<b.start;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
    }
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long index=0;
    for(long long i=k;i<=n;++i)
    {
        v[index].ans=arr[i]-arr[i-k];
        v[index].start=i-k+1;
        index++;
    }
    sort(v,v+index,compare);
    long long count=0;
    vector<long long> finalans;
    long long s,e;
    for(long long i=0;i<index;++i)
    {
        if(i==0)
        {
            finalans.push_back(v[i].start);
            s=v[i].start;
            e=v[i].start+k-1;
        }
        else
        {
            long long t1=v[i].start;
            long long t2=v[i].start+k-1;
            if(t1>e)
            {
                finalans.push_back(t1);
                break;
            }
            else if(t2<s)
            {
                finalans.push_back(t1);
                break;
            }
            else continue;
        }
    }
    sort(finalans.begin(),finalans.end());
    for(long long i=0;i<2;++i)
    {
        cout<<finalans[i]<<" ";
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    /*for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int dp[n+1][3];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];*/
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    return a.ans>b.ans;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    long long brr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long index=0;
    //debug(n);
    for(long long i=k;i<=n;++i)
    {
        v[index].ans=arr[i]-arr[i-k];
        v[index].start=i-k+1;
        index++;
    }
    sort(v,v+index,compare);
    long long count=0;
    vector<long long> finalans;
    long long s,e;
    for(long long i=0;i<index;++i)
    {
        if(i==0)
        {
            finalans.push_back(v[i].start);
            s=v[i].start;
            e=v[i].start+k-1;
            //debug(s,e);
        }
        else
        {
            long long t1=v[i].start;
            long long t2=v[i].start+k-1;
            if(t1>e)
            {
                finalans.push_back(t1);
                break;
            }
            else if(t2<s)
            {
                finalans.push_back(t1);
                break;
            }
            else continue;
        }
        //debugmp(m);
    }
    sort(finalans.begin(),finalans.end());
    for(long long i=0;i<2;++i)
    {
        cout<<finalans[i]<<" ";
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    /*for(int i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    int dp[n+1][3];
    for(int i=0;i<=n;++i)
    {
        for(int j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][k];*/
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    if(a.ans!=b.ans) return a.ans>b.ans;
    else return a.start<b.start;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long dp[n+1][3];
    for(long long i=0;i<=n;++i)
    {
        for(long long j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    long long val=dp[n][2];
    vector<long long> values;
    long long m=2;
    long long x=n;
    while(1)
    {
        while(dp[x-1][m]==val)
        {
            x--;
        }
        values.push_back(x-k);
        val=dp[x-k][m-1];
        x=x-k;
        m--;
        if(m==0) break;
    }
    sort(values.begin(),values.end());
    for(long long i=0;i<values.size();++i)
    {
        cout<<values[i]+1<<" ";
    }
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include<bits/stdc++.h>
using namespace std;

#define real() cout<<"\n";

#define debug(arguments...) {string pri=#arguments;replace(pri.begin(),pri.end(),',',' ');stringstream prii(pri);istream_iterator<string> _iterat(prii);error(_iterat,arguments);}
void error(istream_iterator<string> _iterat) {}
template<typename T,typename...args>
void error(istream_iterator<string> _iterat,T a,args...arguments)
{
    cerr<<*_iterat<<"="<<a<<"\n";
    error(++_iterat,arguments...);
}

#define debugmp(z) {string pri=#z;error(pri,z);}
template<typename T,typename V>
void error(string pri,const pair<T,V> &z)
{
    cerr<<pri<<"="<<"{"<<z.first<<","<<z.second<<"}"<<"\n";
}
template<typename T,typename V>
void error(string pri,const map<T,V> &z)
{
    cerr<<pri<<" is={";
    for(auto it=z.begin();it!=z.end();++it)
    {
        cerr<<it->first<<":"<<it->second;
        auto _it=z.end();
        _it--;
        if(it!=_it) cerr<<",";
    }
    cerr<<"}";
    cerr<<"\n";
}

#define debugc(z,st,ed) {string pri=#z;error(pri,z,st,ed);}
template<typename T>
void error(string pri,const vector<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const set<T> &z,long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    long long tempcount=0;
    for(auto it=z.begin();it!=z.end();++it)
    {
        if(tempcount>=st and tempcount<ed)
        {
            cerr<<*it;
            if(tempcount!=ed-1) cerr<<" ";
        }
        tempcount++;
    }
    cerr<<"]";
    cerr<<"\n";
}
template<typename T>
void error(string pri,const T z[],long long st,long long ed)
{
    cerr<<pri<<" in range["<<st<<","<<ed<<")=[";
    for(long long i=st;i<ed;++i)
    {
        cerr<<z[i];
        if(i!=ed-1) cerr<<" ";
    }
    cerr<<"]";
    cerr<<"\n";
}

struct q
{
    long long ans;
    long long start;
}v[1000*1000];

bool compare(q a,q b)
{
    if(a.ans!=b.ans) return a.ans>b.ans;
    else return a.start<b.start;
}

void logic()
{
    long long n,k;
    cin>>n>>k;
    long long arr[n+1]={0};
    for(long long i=1;i<=n;++i)
    {
        cin>>arr[i];
    }
    //this was to count total cost;
    //how to find segement using knapsack??
    for(long long i=1;i<=n;++i)
    {
        arr[i]=arr[i]+arr[i-1];
    }
    long long dp[n+1][3];
    for(long long i=0;i<=n;++i)
    {
        for(long long j=0;j<=2;++j)
        {
            if(i==0 or j==0) dp[i][j]=0;
            else if(i-k>=0 and j-1>=0) dp[i][j]=max(dp[i-1][j],dp[i-k][j-1]+arr[i]-arr[i-k]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    long long val=dp[n][2];
    vector<long long> values;
    long long m=2;
    for(long long i=n;i>=0;--i)
    {
        if(val==dp[i-1][m]) continue;
        else
        {
            values.push_back(val-dp[i-k][m-1]);
            //debug(i,val-dp[i-k][m-1]);
            val=dp[i-k][m-1];
            m--;
            if(m==0) break;
        }
    }
    //debugc(values,0,values.size());
    bool flag1=0;
    bool flag2=0;
    for(long long i=k;i<=n;++i)
    {
        long long temp=arr[i]-arr[i-k];
        if(values[0]==temp and flag1==0)
        {
            cout<<i-k+1<<" ";
            i=i+k-1;
            flag1=1;
        }
        else if(values[1]==temp and flag2==0)
        {
            cout<<i-k+1<<" ";
            i=i+k-1;
            flag2=1;
        }
        if(flag1==1 and flag2==1) break;
    }
    cout<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long t;
    //cin>>t;
    //while(t--)
    {
        logic();
    }
}


#include <bits/stdc++.h>
using  namespace std;
typedef long long int ll;
#define PB push_back
#define MP make_pair
const int N=2e5+1;
ll dp[N][2] ;
int n , k , l , r;
vector<pair<ll , ll>> ve , ve2;
map <ll , vector<ll>> m;
ll arr[N];
ll cal(int pos , bool fir)
{
     if(pos + k - 1 > n)
     return -1e9;
     if(dp[pos][fir] != -1)
     return dp[pos][fir];
     ll mx;
     if(!fir)
     {
           mx =max(cal(pos+1 , fir) ,(cal(pos+k, 1)+(arr[pos+k-1] - arr[pos-1])));
     }
     else
     mx = max(cal(pos + 1 , fir) , (arr[pos+k-1] - arr[pos - 1]));
     return dp[pos][fir] = mx;
}
int main() {

     scanf("%d%d",&n,&k);
     for(int i = 1 ;i<=n;++i)
     {
          scanf("%d",&arr[i]);
          arr[i]+=arr[i-1];
     }
     memset(dp , -1 , sizeof(dp));
     ll ans = cal(1 , 0);
     for(int i = 1 ; i+k-1 <= n;++i){
     ve.PB({arr[i+k-1] - arr[i-1], i});
     m[arr[i+k-1] - arr[i-1]].PB(i);
     }
     for(int l = 0 ; l < ve.size();++l)
     {
          if(ans - ve[l].first < 0) continue;
          if(m[ans - ve[l].first].size() !=  0){
               for(int i = 0 ; i <  m[ans - ve[l].first] .size(); ++i)
          ve2.PB({m[ans - ve[l].first][i], ve[l].second});
          }

     }
     sort(ve2.begin() , ve2.end());
     for(int i=0 ;i<ve2.size();++i)
     {
          if(ve2[i].second >= ve2[i].first && ve2[i].second <= ve2[i].first + k -1)
          continue;
          else  if(ve2[i].first >= ve2[i].second && ve2[i].first <= ve2[i].second + k -1)
          continue;
          else
          return cout<<ve2[i].first<<" "<<ve2[i].second , 0;
     }

   return 0;
}


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
hugs = 0
i = 0
i_days = None
while True:
    if D[i] >= x:
        hugs += int((D[i] + (D[i]-x+1))/2*x)
        i_days = x
        break
    else:
        hugs += int(D[i]*(D[i]+1)/2)
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(1, n):
    hugs += int(D[j]*(D[j]+1)/2)
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
hugs = 0
i = 0
i_days = None
while True:
    if D[i] >= x:
        hugs += rangesum(D[i]-x+1, D[i])
        i_days = x
        break
    else:
        hugs += rangesum(1,D[i])
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(1, n):
    hugs += rangesum(1,D[j])
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
hugs = 0
i = 0
i_days = None
while True:
    if D[i] >= x:
        hugs += int(x)*int(D[i] + (D[i]-x+1))//2
        i_days = x
        break
    else:
        hugs += int(D[i])*int(D[i]+1)//2
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(1, n):
    hugs += int(D[j])*int(D[j]+1)/2
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
hugs = 0
i = 0
i_days = None
while True:
    if D[i] >= x:
        hugs += (D[i] + (D[i]-x+1))/2*x
        i_days = x
        break
    else:
        hugs += D[i]*(D[i]+1)/2
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(1, n):
    hugs += D[j]*(D[j]+1)/2
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def numhugs(i, x, D):
    hugs = 0
    while True:
        if D[i] >= x:
            hugs += (D[i] + (D[i]-x+1))/2*x
            break
        else:
            hugs += D[i]*(D[i]+1)/2
            x -= D[i]
            i -= 1
    return hugs

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
maxHugs = 0
for i in range(n):
    hugs = numhugs(i,x,D)
    if hugs > maxHugs:
        maxHugs = hugs
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
D = D.extend(x)
i=n,j=n,i_days=None
hugs=0
while True:
    if D[i] >= x:
        hugs += rangesum(D[i]-x+1, D[i])
        i_days = x
        break
    else:
        hugs += rangesum(1,D[i])
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(n+1, 2*n):
    hugs += rangesum(1,D[j])
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
maximum = max(D)
hugs = 0
i = 0
i_days = None
while True:
    if D[i] >= x:
        hugs += x*(D[i] + (D[i]-x+1))/2
        i_days = x
        break
    else:
        hugs += D[i]*(D[i]+1)/2
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(1, n):
    hugs += D[j]*(D[j]+1)/2
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


def rangesum(i, j):
    # inclusive
    return int((j-i+1)*(i+j)/2)

n,x = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
D.extend(D)
i=n
j=n
i_days=None
hugs=0
while True:
    if D[i] >= x:
        hugs += rangesum(D[i]-x+1, D[i])
        i_days = x
        break
    else:
        hugs += rangesum(1,D[i])
        x -= D[i]
        i -= 1
maxHugs = hugs
for j in range(n+1, 2*n):
    hugs += rangesum(1,D[j])
    if i_days >= D[j]:
        hugs -= rangesum(D[i]-i_days+1, D[i]-i_days+D[j])
        i_days -= D[j]
    else:
        hugs -= rangesum(D[i]-i_days+1, D[i])
        i += 1
        y = D[j] - i_days
        while True:
            if D[i] >= y:
                i_days = D[i]-y
                hugs -= rangesum(1,y)
                break
            else:
                y -= D[i]
                hugs -= rangesum(1,D[i])
                i += 1
    maxHugs = max(hugs, maxHugs)
print(int(maxHugs))


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# import sys
# input = sys.stdin.readline

M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]

def givedays(a,b):
    return (b*(b + 1)//2) - (a*(a - 1)//2)

n, x = li()
l = li()
l1 = []
# print(l,x)

l = l + l
for i in l:
    l1.append(i*(i + 1)//2)

if max(l) >= x:
    print(givedays(max(l)-x+1,max(l)))
    exit()

ans = currsum = currdays = i = j = 0
while j < 2*n:
    if l[j] <= x - currdays:
        currdays += l[j]
        currsum += givedays(0,l[j])
    elif l[j] > x - currdays:
        req = x - currdays
        currsum += givedays(0,req)
        currdays += req
        flag = req
        ans = max(ans,currsum)
        req = l[j] - req
        while l[i] <= req:
            currsum -= l1[i]
            req -= l[i]
            i += 1
        currsum -= givedays(0,req)
        # print("CHECK :",currsum)
        l[i] -= req
        l1[i] -= givedays(0,req)
        req = 0
        currsum += givedays(flag,l[j])
    # print(currsum)
    ans = max(ans,currsum)
    j += 1

print(ans)


# from bisect import bisect_left as bl
# from bisect import bisect_right as br
# from heapq import heappush,heappop
# import math
# from collections import *
# from functools import reduce,cmp_to_key,lru_cache
# from itertools import accumulate
# import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# # import sys
# # input = sys.stdin.readline

# M = mod = 10**9 + 7
# def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
# def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]

n, x = li()
l = li()
l = l + l

startindices = [0 for i in l]

i = j = ans = curr = days = 0
while j < 2*n:
    if days + l[j] <= x:
        days += l[j]
        curr += (l[j] * (l[j] + 1))//2
    else:
        while l[j] + days - (l[i] - startindices[i] ) > x:
            left = startindices[i]
            days -= l[i] - left

            curr -= (l[i] * (l[i] + 1))//2 - (left * (left + 1))//2
            i += 1

        deletetill = l[j] + days - x

        left = startindices[i]
        curr -= (left + deletetill) *( left + deletetill + 1)//2 - (left * (left + 1))//2
        startindices[i] += deletetill

        days = x
        curr += l[j] * (l[j] + 1)//2
    ans = max(ans,curr)

    j += 1
print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
from itertools import accumulate
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# import sys
# input = sys.stdin.readline

M = mod = 10**9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip().split()]
def st():return str(input().rstrip())[2:-1]
def val():return int(input().rstrip())
def li2():return [str(i)[2:-1] for i in input().rstrip().split()]
def li3():return [int(i) for i in st()]

n, x = li()
l = li()
l = l + l

startindices = [0 for i in l]

i = j = ans = curr = days = 0
while j < 2*n:
    if days + l[j] <= x:
        days += l[j]
        curr += (l[j] * (l[j] + 1))//2
    else:
        while l[j] + days - (l[i] - startindices[i] ) > x:
            left = startindices[i]
            days -= l[i] - left

            curr -= (l[i] * (l[i] + 1))//2 - (left * (left + 1))//2
            i += 1

        deletetill = l[j] + days - x

        left = startindices[i]
        curr -= (left + deletetill) *( left + deletetill + 1)//2 - (left * (left + 1))//2
        startindices[i] += deletetill

        days = x
        curr += l[j] * (l[j] + 1)//2
    ans = max(ans,curr)

    j += 1
print(ans)


from sys import stdin, gettrace

if not gettrace():
    def input():
        return next(stdin)[:-1]

# def input():
#    return stdin.buffer.readline()

def main():
    def solve():
        n,k=map(int,input().split())
        li=[0]+[int(x) for x in input().split()]
        for i in range(n):
            li.append(li[i])
        pref1=[0]*(2*n+1)
        pref2=[0]*(2*n+1)
        pref1[1]=((li[1]*(li[1]+1))//2)
        pref2[1]=li[1]
        for i in range(2,2*n+1):
            pref1[i]=pref1[i-1]+((li[i]*(li[i]+1))//2)
            pref2[i]=pref2[i-1]+li[i]
        mx=0
        for i in range(2*n,n-1,-1):
            ans=i
            low,high=1,i
            while low<=high:
                mid=(low+high)//2
                if pref2[i]-pref2[mid]<k:
                    high=mid-1
                    ans=mid
                else:
                    low=mid+1
            rem=pref2[i]-pref2[ans-1]-k
            val=pref1[i]-pref1[ans-1]-((rem*(rem+1))//2)
            mx=max(val,mx)
        print(mx)
    solve()

if __name__ == "__main__":
    main()


from sys import stdin, gettrace

if not gettrace():
    def input():
        return next(stdin)[:-1]

# def input():
#    return stdin.buffer.readline()

def main():
    def solve():
        n,k=map(int,input().split())
        li=[0]+[int(x) for x in input().split()]
        for i in range(n):
            li.append(li[i])
        pref1=[0]*(2*n+1)
        pref2=[0]*(2*n+1)
        pref1[1]=((li[1]*(li[1]+1))//2)
        pref2[1]=li[1]
        for i in range(2,2*n+1):
            pref1[i]=pref1[i-1]+((li[i]*(li[i]+1))//2)
            pref2[i]=pref2[i-1]+li[i]
        mx=0
        for i in range(2*n,n-1,-1):
            ans=i
            low,high=0,i
            while low<=high:
                mid=(low+high)//2
                if pref2[i]-pref2[mid]<k:
                    high=mid-1
                    ans=mid
                else:
                    low=mid+1
            rem=pref2[i]-pref2[ans-1]-k
            val=pref1[i]-pref1[ans-1]-((rem*(rem+1))//2)
            mx=max(val,mx)
        print(mx)
    solve()

if __name__ == "__main__":
    main()


from sys import stdin, gettrace

if not gettrace():
    def input():
        return next(stdin)[:-1]

# def input():
#    return stdin.buffer.readline()

def main():
    def solve():
        n,k=map(int,input().split())
        li=[0]+[int(x) for x in input().split()]
        for i in range(n):
            li.append(li[i])
        pref1=[0]*(2*n+1)
        pref2=[0]*(2*n+1)
        pref1[1]=((li[1]*(li[1]+1))//2)
        pref2[1]=li[1]
        for i in range(2,2*n+1):
            pref1[i]=pref1[i-1]+((li[i]*(li[i]+1))//2)
            pref2[i]=pref2[i-1]+li[i]
        mx=0
        for i in range(2*n,n-1,-1):
            ans=i
            low,high=1,i
            while low<=high:
                mid=(low+high)//2
                if pref2[i]-pref2[mid]<k:
                    high=mid-1
                    ans=mid
                else:
                    ans=mid
                    low=mid+1
            rem=pref2[i]-pref2[ans-1]-k
            val=pref1[i]-pref1[ans-1]-((rem*(rem+1))//2)
            mx=max(val,mx)
        print(mx)
    solve()

if __name__ == "__main__":
    main()


from sys import stdin
import os
import sys
from io import BytesIO, IOBase
# fast-io region

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

def input():
    return sys.stdin.readline().rstrip("\r\n")
#fast i/o region end

n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=arr*2
i=j=ans=td=days=0
while(i<n):
    while(days<m):
        days+=arr[j]
        td+=(arr[j])*(arr[j]+1)//2
        j=j+1
    ans=max(ans,td-(days-m)*(days-m+1)//2)
    days-=arr[i]
    td-=arr[i]*(arr[i]+1)//2
    i=i+1
print(ans)


from sys import stdin
import os
import sys
from io import BytesIO, IOBase
# fast-io region

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

def input():
    return sys.stdin.readline().rstrip("\r\n")
#fast i/o region end

n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=arr*2
i=j=ans=td=days=0
ma=max(arr)
print(ma*(ma+1)//2-(ma-m)*(ma-m+1)//2)


n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=arr*2
i=j=ans=td=days=0
while(i<n):
    while(days<m):
        days+=arr[j]
        td+=(arr[j])*(arr[j]+1)//2
        j=j+1
    ans=max(ans,td-(days-m)*(days-m+1)//2)
    days-=arr[i]
    td-=arr[i]*(arr[i]+1)//2
    i=i+1
print(ans)


import sys

def getAp(n):
	return (n*(n+1))//2

n , x = (int(var) for var in sys.stdin.readline().strip().split())
months = [int(var) for var in sys.stdin.readline().strip().split()]
months += months

hugs, days = [0 for _ in range(2*n)], [0 for _ in range(2*n)]
hugs[-1], days[-1] = getAp(months[-1]), months[-1]

for i in reversed(range(2*n-1)):
	hugs[i] = hugs[i+1] + getAp(months[i])
	days[i] += days[i+1] + months[i]
days.append(0)
hugs.append(0)
maxHugs = 0

for invx in reversed(range(2*n)):

	l , r = 0, invx
	offset, store = days[invx+1], None
	while l <= r:
		mid = (l+r)//2
		dayCalc = days[mid] - offset
		if dayCalc == x:
			store = mid
			break
		elif dayCalc < x :
			store = mid
			r = mid - 1
		else:
			l = mid + 1
	if store is None:
		maxHugs = max(maxHugs, getAp(months[invx]) - getAp(months[invx]-x))
	else:
		tempHugs = hugs[store] - hugs[invx+1]
		daysLeft = x - (days[store] - offset)
		if store - 1 >= 0:
			tempHugs += getAp(months[store-1]) - getAp(months[store-1] - daysLeft)
		else:
			maxHugs = max(maxHugs,  tempHugs)
			break
		maxHugs = max(maxHugs,  tempHugs)

print(maxHugs)


# from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
# sys.setrecursionlimit(10**6)
input = stdin.readline
# print = stdout.write

# @lru_cache()
n,m=map(int,input().split())
ar=list(map(int,input().split()))
ar=ar+ar
d=[0]
h=[0]
for i in range(2*n):
	d.append(d[-1]+ar[i])
	h.append(h[-1]+(ar[i]*(ar[i]+1))//2)

# print(d)
# print(h)
ans=0
for i in range(1,2*n+1):
	if(d[i]>=m):
		req=d[i]-m
		l=0
		r=i+1
		ind=0
		while(l<=r):
			mid=(l+r)//2
			if(d[mid]<req):
				l=mid+1
			else:
				ind=mid
				r=mid-1
		if(ind==0 or d[i]-d[ind]==m):
			ans=max(ans,h[i]-h[ind])
		# print(ind,i)
		else:
			rslt=h[i]-h[ind]
			req = m-(d[i]-d[ind])
			temp = (ar[ind-1]*(ar[ind-1]+1))//2-((ar[ind-1]-req)*(ar[ind-1]-req+1))//2
			ans=max(ans,rslt+temp)

print(ans)


# -*- coding: utf-8 -*-

import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1

def read_int():
    return int(buff_readline())

def read_int_n():
    return list(map(int, buff_readline().split()))

def read_float():
    return float(buff_readline())

def read_float_n():
    return list(map(float, buff_readline().split()))

def read_str():
    return readline().strip()

def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)

def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

def slv(N, X, D):
    def f(n):
        return (n**2 + n) // 2

    yh = sum(map(f, D))
    yn = sum(D)

    D.reverse()
    D += D
    sd = [0]
    sh = [0]
    for d in D:
        sd.append(sd[-1]+d)
        sh.append(sh[-1]+f(d))
    o = (X // yn) * yh
    X %= yn
    ans = 0
    for i in range(N):
        j = Bisect(lambda x: sd[x]-sd[i]).bisect_left(X+1, i, i+N)
        u = sd[j] - sd[i]
        r = u - X
        t = sh[j-1] - sh[i] + f(D[j-1]) - f(r)
        ans = max(ans, o+t)

    return ans

def main():
    N, X = read_int_n()
    D = read_int_n()
    print(slv(N, X, D))

if __name__ == '__main__':
    main()