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

using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    int csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] >= suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k-1; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}


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

using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    ll csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] >= suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k-1; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}


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

using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    ll csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] >= suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    assert(ai != -1);
    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}


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

using ll = long long;
using ld = long double;
using pii = pair<ll, int>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    int csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] > suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k-1; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}


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

using ll = long long;
using ld = long double;
using pii = pair<ll, int>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    int csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] >= suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k-1; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

//ans==true?cout<<"YES"<<endl:cout<<"NO"<<endl;
pii mexSum(ll * a, ll en, ll k, ll st) {
	ll mex = -INF;
	ll sum = 0;
	ll ind = -1;
	fa(i, st, st + k) {
		sum += a[i];
	}
	mex = max(mex, sum);
	ind = st;
	fa(i, st + k, en + 1) {
		sum += a[i];
		sum -= a[i - k];
		//mex = max(mex,sum);
		if (sum > mex) {
			sum = mex;
			ind = i - k + 1;
		}
	}
	return mp(ind, mex);
}
int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll b[n];
	ll index = n - 1;
	f(i, n) {
		b[i] = a[index--];
	}
	ll ansFirst = -1;
	ll ansSecond = -1;
	ll ansMex = -INF;
	pii check1 = mexSum(a, n - k - 1, k, 0);
	pii check2 = mexSum(a, n - 1, k, check1.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;

	pii check3 = mexSum(b, n - k - 1, k, 0);
	pii check4 = mexSum(b, n - 1, k, check3.ff + k);
	if ((check1.ss + check2.ss) >= (check3.ss + check4.ss)) {
		ansFirst = check1.ff + 1; ansSecond = check2.ff + 1;
	}
	else {
		//cout << check3.ff << " " << check4.ff << endl;
		ansFirst = n - check3.ff - 1 ; ansSecond = n - check4.ff - 1;
		//cout << ansFirst << " " << ansSecond << endl;
	}
	cout << min(ansFirst, ansSecond) << " " << max(ansFirst, ansSecond) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

//ans==true?cout<<"YES"<<endl:cout<<"NO"<<endl;
pii mexSum(ll * a, ll en, ll k, ll st) {
	ll mex = -INF;
	ll sum = 0;
	ll ind = -1;
	fa(i, st, st + k) {
		sum += a[i];
	}
	mex = max(mex, sum);
	ind = st;
	fa(i, st + k, en + 1) {
		sum += a[i];
		sum -= a[i - k];
		//mex = max(mex,sum);
		if (sum > mex) {
			mex = sum;
			ind = i - k + 1;
		}
	}
	return mp(ind, mex);
}
int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll b[n];
	ll index = n - 1;
	f(i, n) {
		b[i] = a[index--];
	}
	ll ansFirst = -1;
	ll ansSecond = -1;
	ll ansMex = -INF;
	pii check1 = mexSum(a, n - k - 1, k, 0);
	pii check2 = mexSum(a, n - 1, k, check1.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;

	pii check3 = mexSum(b, n - k - 1, k, 0);
	pii check4 = mexSum(b, n - 1, k, check3.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;
	//cout << check1.ss << " " <<  check2.ss << " " << check3.ss << " " << check4.ss << endl;
	if ((check1.ss + check2.ss) >= (check3.ss + check4.ss)) {
		ansFirst = check1.ff + 1; ansSecond = check2.ff + 1;
	}
	else {
		//cout << check3.ff << " " << check4.ff << endl;
		ansFirst = n - check3.ff - 1 ; ansSecond = n - check4.ff - 1;
		//cout << ansFirst << " " << ansSecond << endl;
	}
	cout << min(ansFirst, ansSecond) << " " << max(ansFirst, ansSecond) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

//ans==true?cout<<"YES"<<endl:cout<<"NO"<<endl;
pii mexSum(ll * a, ll en, ll k, ll st) {
	ll mex = -INF;
	ll sum = 0;
	ll ind = -1;
	fa(i, st, st + k) {
		sum += a[i];
	}
	mex = max(mex, sum);
	ind = st;
	fa(i, st + k, en + 1) {
		sum += a[i];
		sum -= a[i - k];
		//mex = max(mex,sum);
		if (sum > mex) {
			mex = sum;
			ind = i - k + 1;
		}
	}
	return mp(ind, mex);
}

pii mexSum2(ll * a, ll en, ll k, ll st) {
	ll mex = -INF;
	ll sum = 0;
	ll ind = -1;
	fa(i, st, st + k) {
		sum += a[i];
	}
	mex = max(mex, sum);
	ind = st;
	fa(i, st + k, en + 1) {
		sum += a[i];
		sum -= a[i - k];
		//mex = max(mex,sum);
		if (sum >= mex) {
			mex = sum;
			ind = i - k + 1;
		}
	}
	return mp(ind, mex);
}

int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll b[n];
	ll index = n - 1;
	f(i, n) {
		b[i] = a[index--];
	}
	ll ansFirst = -1;
	ll ansSecond = -1;
	ll ansMex = -INF;
	pii check1 = mexSum(a, n - k - 1, k, 0);
	pii check2 = mexSum(a, n - 1, k, check1.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;

	pii check3 = mexSum2(b, n - k - 1, k, 0);
	pii check4 = mexSum2(b, n - 1, k, check3.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;
	//cout << check1.ss << " " <<  check2.ss << " " << check3.ss << " " << check4.ss << endl;
	if ((check1.ss + check2.ss) >= (check3.ss + check4.ss)) {
		ansFirst = check1.ff + 1; ansSecond = check2.ff + 1;
	}
	else {
		//cout << check3.ff << " " << check4.ff << endl;
		ansFirst = n - check3.ff - 1 ; ansSecond = n - check4.ff - 1;
		//cout << ansFirst << " " << ansSecond << endl;
	}
	cout << min(ansFirst, ansSecond) << " " << max(ansFirst, ansSecond) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll check[n];
	mem(check, 0);
	ll sum = 0;
	f(i, k) {
		sum += a[i];
	}
	check[0] = sum;
	fa(i, k, n) {
		sum += a[i];
		sum -= a[i - k];
		check[i - k + 1] = sum;
	}
	ll dp[n];
	mem(dp, 0);
	ll abhiTak = -INF;
	ll picheWalaIndex = -1;
	// f(i, n) {
	// 	cout << check[i] << " ";
	// }
	// cout << endl;
	far(i, n - k, -1) {
		if (check[i] >= abhiTak) {
			abhiTak = check[i];
			picheWalaIndex = i;
		}
		dp[i] = picheWalaIndex;
	}
	ll ans = -INF;
	ll ansFirst = -1;
	ll ansSecond = -1;
	f(i, n - k) {
		ll here = check[i] + check[dp[i + k]];
		if (here > ans) {
			ans = here;
			ansFirst = i + 1;
			ansSecond = dp[i + k] + 1;
		}
	}
	cout << ansFirst << " " << ansSecond << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll check[n];
	mem(check, 0);
	ll sum = 0;
	f(i, k) {
		sum += a[i];
	}
	check[0] = sum;
	fa(i, k, n) {
		sum += a[i];
		sum -= a[i - k];
		check[i - k + 1] = sum;
	}
	ll dp[n];
	mem(dp, -1);
	ll abhiTak = -INF;
	ll picheWalaIndex = -1;
	// f(i, n) {
	// 	cout << check[i] << " ";
	// }
	// cout << endl;
	far(i, n - k, -1) {
		if (check[i] >= abhiTak) {
			abhiTak = check[i];
			picheWalaIndex = i;
		}
		dp[i] = picheWalaIndex;
	}
	// f(i, n) {
	// 	cout << dp[i] << " ";
	// }
	// cout << endl;
	ll ans = -INF;
	ll ansFirst = -1;
	ll ansSecond = -1;
	f(i, n - k) {
		ll here = check[i] + check[dp[i + k]];
		if (here > ans) {
			ans = here;
			ansFirst = i + 1;
			ansSecond = dp[i + k] + 1;
		}
	}
	cout << ansFirst << " " << ansSecond << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll check[n];
	mem(check, 0);
	ll sum = 0;
	f(i, k) {
		sum += a[i];
	}
	check[0] = sum;
	fa(i, k, n) {
		sum += a[i];
		sum -= a[i - k];
		check[i - k + 1] = sum;
	}
	ll dp[n];
	mem(dp, -1);
	ll abhiTak = -INF;
	ll picheWalaIndex = -1;
	// f(i, n) {
	// 	cout << check[i] << " ";
	// }
	// cout << endl;
	far(i, n - k, -1) {
		if (check[i] >= abhiTak) {
			abhiTak = check[i];
			picheWalaIndex = i;
		}
		dp[i] = picheWalaIndex;
	}
	// f(i, n) {
	// 	cout << dp[i] << " ";
	// }
	// cout << endl;
	ll ans = -INF;
	ll ansFirst = -1;
	ll ansSecond = -1;
	f(i, n - (2 * k) + 1) {
		ll here = check[i] + check[dp[i + k]];
		if (here > ans) {
			ans = here;
			ansFirst = i + 1;
			ansSecond = dp[i + k] + 1;
		}
	}
	cout << ansFirst << " " << ansSecond << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define rem 1000000007
#define MAX 99999999

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
#define v(x) vector<x>
#define pb(x) push_back(x)
#define ppb() pop_back()
#define mp(x,y) make_pair(x,y)
#define mii map<ll,ll>
#define umii unordered_map<ll,ll>
#define mxheap priority_queue<ll> // Max Heap
#define mnheap priority_queue<ll,vi,greater<ll> > // Min Heap
#define da(type,arr,size) type *arr = new type[n] // Dynamically allocated array

#define f(i,n) for(ll i=0;i<(n);i++)
#define fa(i,a,b) for(ll i=(a);i<(b);i++)
#define far(i,a,b) for(ll i=(a);i>(b);i--)
#define T ll t; cin>>t; while(t--)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define sz size()

#define setbits(x) __builtin_popcountll(x) // Total set bits in a number
#define zerobits(x) __builtin_ctzll(x) // This will tell me number of zeroes till first set bit
#define all(c) (c).begin(),(c).end()
#define setp(x,y) fixed<<setprecision(y)<<x
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define INF 2e18

ll mod(ll n) {
	return n > 0 ? n : -1 * n;
}
ld dist(ll x1, ll y1, ll x2, ll y2) {
	ld ans = round(pow(mod(x2 - x1), 2)) + round(pow(mod(y2 - y1), 2));
	ans = sqrt(ans);
	return ans;
}

// ld dist(pii a, pii b) {
// 	ld ans = round(pow(mod(b.ff - a.ff), 2)) + round(pow(mod(b.ss - a.ss), 2));
// 	ans = sqrt(ans);
// 	return ans;
// }
umii isPrime;
void SieveOfEratosthenes(ll n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));

	for (ll p = 2; p * p <= n; p++)
	{
		if (prime[p] == true)
		{
			for (ll i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (ll p = 2; p <= n; p++)
		if (prime[p])
			isPrime[p] = 1;;
}
ll binaryToDecimal(vi& num)
{
	//string num = n;
	ll dec_value = 0;

	// Initializing base value to 1, i.e 2^0
	ll base = 1;

	ll len = num.size();
	for (ll i = 0; i < len; i++) {
		if (num[i] == 1)
			dec_value += base;
		base = base * 2;
	}

	return dec_value;
}

// ll power_mod(ll x, ll y, ll p)
// {
// 	ll res = 1;     // Initialize result

// 	x = x % p; // Update x if it is more than or
// 	// equal to p

// 	if (x == 0) return 0; // In case x is divisible by p;

// 	while (y > 0)
// 	{
// 		// If y is odd, multiply x with result
// 		if (y & 1)
// 			res = (res * x) % p;

// 		// y must be even now
// 		y = y >> 1; // y = y/2
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll power(ll x, ll y) {
// 	if (x == 0) {
// 		return 0;
// 	}
// 	if (y == 0) {
// 		return 1;
// 	}

// 	ll smallAns = power(x, y / 2);
// 	if (y % 2 == 0) {
// 		return smallAns * smallAns;
// 	}
// 	else {
// 		return smallAns * smallAns * x;
// 	}
// }

ll sq(ll n) {
	return (n * n);
}

// ll gcdExtended(ll a, ll b, ll *x, ll *y);

// // Function to find modulo inverse of a
// ll modInverse(ll a, ll m)
// {
// 	ll x, y;
// 	ll g = gcdExtended(a, m, &x, &y);
// 	ll res = (x % m + m) % m;
// 	return res;

// }

// ll gcdExtended(ll a, ll b, ll *x, ll *y)
// {
// 	// Base Case
// 	if (a == 0)
// 	{
// 		*x = 0, *y = 1;
// 		return b;
// 	}

// 	ll x1, y1; // To store results of recursive call
// 	ll gcd = gcdExtended(b % a, a, &x1, &y1);

// 	// Update x and y using results of recursive
// 	// call
// 	*x = y1 - (b / a) * x1;
// 	*y = x1;

// 	return gcd;
// }

void primeFactors(ll n, umii& mp)
{
	while (n % 2 == 0)
	{
		mp[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			mp[i]++;
			n = n / i;
		}
	}
	if (n > 2)
		mp[n]++;
}

void decToBinary(ll n, vi& binaryNum)
{
	ll i = 0;
	while (n > 0) {
		binaryNum[i] = n % 2;
		n = n / 2;
		i++;
	}
}

//ans==true?cout<<"YES"<<endl:cout<<"NO"<<endl;
pii mexSum(ll * a, ll en, ll k, ll st) {
	ll mex = -INF;
	ll sum = 0;
	ll ind = -1;
	fa(i, st, st + k) {
		sum += a[i];
	}
	mex = max(mex, sum);
	ind = st;
	fa(i, st + k, en + 1) {
		sum += a[i];
		sum -= a[i - k];
		//mex = max(mex,sum);
		if (sum > mex) {
			sum = mex;
			ind = i - k + 1;
		}
	}
	return mp(ind, mex);
}
int main() {
	fast
	ll n, k;
	cin >> n >> k;
	ll a[n];
	f(i, n) {
		cin >> a[i];
	}
	ll b[n];
	ll index = n - 1;
	f(i, n) {
		b[i] = a[index--];
	}
	ll ansFirst = -1;
	ll ansSecond = -1;
	ll ansMex = -INF;
	pii check1 = mexSum(a, n - k, k, 0);
	pii check2 = mexSum(a, n - 1, k, check1.ff + k);
	//cout << check1.ff << " " << check2.ff << endl;

	pii check3 = mexSum(b, n - k, k, 0);
	pii check4 = mexSum(b, n - 1, k, check3.ff + k);
	if ((check1.ss + check2.ss) >= (check3.ss + check4.ss)) {
		ansFirst = check1.ff + 1; ansSecond = check2.ff + 1;
	}
	else {
		ansFirst = n - check3.ff - 1 ; ansSecond = n - check4.ff - 1;
	}
	cout << min(ansFirst, ansSecond) << " " << max(ansFirst, ansSecond) << endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    int x[n],p2,p1,sum=0,maxi=0;
    vector<int> v;
    int dp[n],ans[n],a=0,b=0;
    For(i,n)
    {
        scanf("%d", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    int maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
//        cout<<i<<" "<<dp[i-k]<<" "<<ans[i]<<endl;
        if(dp[i-k] + ans[i] >= maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb =ans[i];
            }
            if(ans[i] > maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k] > maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb = ans[i];
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
ll max(ll a, ll b)
{
    if(a>b)
        return a;
    return b;
}
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    vector<ll> v;
    ll x[n],dp[n],ans[n],a=0,b=0,sum=0,maxi=0;
    For(i,n)
    {
        scanf("%lld", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    ll maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k] + ans[i] >= maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb =ans[i];
            }
            if(ans[i] > maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k] > maxa)
            {
                a = i-k+1;
                maxa = dp[i-k];
                if(b-a<k)
                {
                    b = i+1;
                    maxb = ans[i];
                }
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
ll max(ll a, ll b)
{
    if(a>b)
        return a;
    return b;
}
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    ll x[n],sum=0,maxi=0;
    vector<ll> v;
    int dp[n],ans[n],a=0,b=0;
    For(i,n)
    {
        scanf("%lld", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    ll maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k] + ans[i] >= maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb =ans[i];
            }
            if(ans[i] > maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k] > maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb = ans[i];
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
using namespace std;
const int s = 2e5 +9;
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    int x[n],p2,p1,sum=0,maxi=0;
    vector<int> v;
    int dp[n],ans[n],a=0,b=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    int maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k] + ans[i] > maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                maxa = dp[i-k];
            }
            if(!maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k]>maxa)
            {
                a = i-k+1;
                maxa = dp[i-k];
            }
            if(maxb<ans[i-k])
            {
                maxb = ans[i];
                b = i+1;
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
ll max(ll a, ll b)
{
    if(a>b)
        return a;
    return b;
}
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    ll x[n],sum=0,maxi=0;
    vector<ll> v;
    int dp[n],ans[n],a=0,b=0;
    For(i,n)
    {
        scanf("%lld", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    int maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
//        cout<<i<<" "<<dp[i-k]<<" "<<ans[i]<<endl;
        if(dp[i-k] + ans[i] >= maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb =ans[i];
            }
            if(ans[i] > maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k] > maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb = ans[i];
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
using namespace std;
const int s = 2e5 +9;
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    int x[n],p2,p1,sum=0,maxi=0;
    vector<int> v;
    int dp[n],ans[n],a=0,b=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    int maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k] + ans[i] > maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                maxa = dp[i-k];
            }
            if(!maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k]>maxa)
            {
                a = i-k+1;
                maxa = dp[i-k];
            }
            if(ans[i]>maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
ll max(ll a, ll b)
{
    if(a>b)
        return a;
    return b;
}
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    vector<ll> v;
    ll x[n],ans[n],a=0,b=0,sum=0,maxi=0;
    vector<pair<ll,int> > dp(n);
    For(i,n)
    {
        scanf("%lld", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k].first = maxi;
            if(i>k)
            {
                if(dp[i-k].first > dp[i-k-1].first)
                    dp[i-k].second = i-k+1;
                else
                    dp[i-k].second = dp[i-k-1].second;
            }
            if(i==k)
                dp[i-k].second = 1;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    ll maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k].first + ans[i] > maxi)
        {
            maxi = dp[i-k].first + ans[i];
            a = dp[i-k].second;
            b =  i+1;
        }
    }
    cout<<a<<" "<<b;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
using namespace std;
const int s = 2e5 +9;
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    int x[n],p2,p1,sum=0;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        scanf("%d", &x[i]);
        if(i>=k)
        {
            v.pb(sum);
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    v.pb(sum);
    if(2*k>=n)
        cout<<1<<" "<<1+k;
    else
    {
        int a=0,b=0,maxi=0;
        for(int i=0;i<v.size();i++)
        {
            for(int j=i+k;j<v.size();j++)
            {
                if(v[i]+v[j]>maxi)
                {
                    maxi = v[i]+v[j];
                    a = i+1,b = j+1;
                }
            }
        }
        cout<<a<<" "<<b;
    }
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define w(t) int t;scanf("%d",&t);while(t--)
#define For(i,n) for(int i=0;i<n;i++)
using namespace std;
const int s = 2e5 +9;
ll max(ll a, ll b)
{
    if(a>b)
        return a;
    return b;
}
int main()
{
    int n,k;scanf("%d%d", &n, &k);
    vector<ll> v;
    ll x[n],dp[n],ans[n],a=0,b=0,sum=0,maxi=0;
    For(i,n)
    {
        scanf("%lld", &x[i]);
        if(i>=k)
        {
            maxi = max(maxi,sum);
            dp[i-k] = maxi;
            ans[i-k] = sum;
            sum-=x[i-k];
        }
        sum+=x[i];
    }
    maxi=0;
    ll maxa=0,maxb=0;
    ans[n-k] = sum;
    for(int i=k;i<=n-k;i++)
    {
        if(dp[i-k] + ans[i] >= maxi)
        {
            maxi = dp[i-k] + ans[i];
            if(!maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb =ans[i];
            }
            if(ans[i] > maxb)
            {
                maxb = ans[i];
                b = i+1;
            }
            if(dp[i-k] > maxa)
            {
                a = i-k+1;
                b = i+1;
                maxa = dp[i-k];
                maxb = ans[i];
            }
        }
    }
    cout<<a<<" "<<b;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 4e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1 = 0, ans2 = 0;
	ll mx = 0;
	forn(i,0,n-k+1)
	{
		b[i] = pref[i+k] - pref[i];
		//cout << b[i] << ' ' ;
	}
	//ed;
	forn(i,0,n-k+1)
	{
		//cout << b[i+k] + b[ans1] << ' ';
		if(b[i+k] + b[ans1] > mx)
		{
			mx = b[i+k] + b[ans1];
			ans2 = i+k;
			//cout << ans2;ed;
		}
		//cout << b[i+k] + b[i] << ' ';
		if(b[i] + b[i+k] >= mx && b[i] > b[ans1])
		{
			mx = b[i] + b[i+k];
			ans1 = i;
			ans2 = i+k;
			//cout << ans1 << ' ' << ans2;ed;
		}
		//cout << mx;ed;
	}
	if(ans1+1 == 27600 && ans2+1 == 79450)
		cout << b[27600-1] << ' ' << b[79450-1] << ' ' << b[89359] << '\n';
	cout << ans1+1 << ' ' << ans2+1;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 4e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1 = 0, ans2 = 0;
	ll mx = 0;
	forn(i,0,n-k+1)
	{
		b[i] = pref[i+k] - pref[i];
		//cout << b[i] << ' ' ;
	}
	//ed;
	forn(i,0,n-k+1)
	{
		//cout << b[i+k] + b[ans1] << ' ';
		if(b[i+k] + b[ans1] > mx)
		{
			mx = b[i+k] + b[ans1];
			ans2 = i+k;
			//cout << ans2;ed;
		}
		//cout << b[i+k] + b[i] << ' ';
		if(b[i] + b[i+k] >= mx && b[i] > b[ans1])
		{
			mx = b[i] + b[i+k];
			ans1 = i;
			ans2 = i+k;
			//cout << ans1 << ' ' << ans2;ed;
		}
		//cout << mx;ed;
	}
	cout << ans1+1 << ' ' << ans2+1;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 4e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1 = 0, ans2 = 0;
	ll mx = 0;
	forn(i,0,n-k+1)
	{
		b[i] = pref[i+k] - pref[i];
		//cout << b[i] << ' ' ;
	}
	//ed;
	forn(i,0,n-k+1)
	{
		//cout << b[i+k] + b[ans1] << ' ';
		if(b[i+k] + b[ans1] > mx)
		{
			mx = b[i+k] + b[ans1];
			ans2 = i+k;
			//cout << ans2;ed;
		}
		//cout << b[i+k] + b[i] << ' ';
		if(b[i] + b[i+k] >= mx && b[i] > b[ans1])
		{
			mx = b[i] + b[i+k];
			ans1 = i;
			ans2 = i+k;
			//cout << ans1 << ' ' << ans2;ed;
		}
		if(i+k - ans2 >= k && b[i+k] + b[ans2] > mx)
		{
			ans1 = ans2;
			ans2 = i+k;
			mx = b[i+k] + b[ans2];
		}
		//cout << mx;ed;
	}
	/*if(ans1+1 == 27600 && ans2+1 == 79450)
		cout << b[27600-1] << ' ' << b[79450-1] << ' ' << b[89359] << '\n';
	*/
	cout << ans1+1 << ' ' << ans2+1;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 4e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		int x;
		cin >> x;
		pref[i] = pref[i-1] + x;
	}
	rfor(i,n,k) {
        pref[i] -= pref[i - k];
    }

    int A = 1, B = k + 1;
    ll res = pref[k] + pref[k + k];
    b[k] = k;
    forn(i,k+1,n+1)
    {
        if (i >= k + k)
        {
            ll cand = pref[i] + pref[i - k];
            ll ca = b[i - k] - k + 1, cb = i - k + 1;
            if (cand > res || (cand == res && ca < A) || (cand == res && ca == A && cb < B))
            {
                res = cand;
                A = ca;
                B = cb;
            }
        }
        if (pref[i] > pref[i - 1])
        {
            b[i] = i;
        }
        else
        {
            b[i] = b[i - 1];
            pref[i] = pref[i - 1];
        }
    }

    cout << A << " " << B << endl;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 2e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1, ans2;
	ll mx = 0;
	forn(i,0,n-2*k+1)
	{
		ll sum = pref[i+k] - pref[i];
		forn(j,i+k,n-k+1)
		{
			if(sum + pref[j+k] - pref[j] > mx)
			{
				ans1 = i+1;
				ans2 = j+1;
				mx = sum + pref[j+k] - pref[j];
			}
		}
	}
	cout << ans1 << ' ' << ans2;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 2e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1 = 0, ans2 = 0;
	ll mx = 0;
	forn(i,0,n-k+1)
	{
		b[i] = pref[i+k] - pref[i];
		//cout << b[i] << ' ' ;
	}
	//ed;
	forn(i,0,n-2*k+1)
	{
		//cout << b[i+k] + b[ans1] << ' ';
		if(b[i+k] + b[ans1] > mx)
		{
			mx = b[i+k] + b[ans1];
			ans2 = i+k;
			//cout << ans2;ed;
		}
		//cout << b[i+k] + b[i] << ' ';
		if(b[i] + b[i+k] >= mx && b[i] > b[ans1])
		{
			mx = b[i] + b[i+k];
			ans1 = i;
			ans2 = i+k;
			//cout << ans1 << ' ' << ans2;ed;
		}
		//cout << mx;ed;
	}
	cout << ans1+1 << ' ' << ans2+1;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (ll)x.size()
#define NAME "sort"
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e15+1234;
const int N = 2e5 + 1234;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll a[N],pref[N],b[N];

void solve()
{
	int n,k;
	cin >> n >> k;

	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}

	for(int i = n; i >= k;i--) {
		pref[i] -= pref[i-k];
	}

	int ans1 = 1,ans2 = k+1;
	ll mx = pref[k] + pref[k+k];
	b[k] = k;

	for(int i = k+1; i <= n; i++) {
		if(i >= k+k) {
			int temp = pref[i] + pref[i-k];
			int tans1 = b[i-k]-k+1;
			int tans2 = i-k+1;
			if(temp > mx || (temp == mx && tans1 < ans1) || (temp == mx && tans1 == ans1 && tans2 < ans2)) {
				mx = temp;
				ans1 = tans1;
				ans2 = tans2;
			}
		}
		if(pref[i] > pref[i-1]) {
			b[i] = i;
		}	else {
			b[i] = b[i-1];
			pref[i] = pref[i-1];
		}
	}
	cout << ans1 << ' ' << ans2;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	//precalc();
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (int)x.size()
#define forn(a,b,c) for(int a = b; a < c; a++)
#define rfor(a,b,c) for(int a = b; a >= c; a--)
#define fors(a,b,c,d) for(int a = b; a < c; a+=d)
#define rfors(a,b,c,d) for(int a = b; a >= c; a-=d)
#define yes cout << "YES"
#define no cout << "NO"
#define NAME ""
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e9+1234;
const int N = 2e5 + 5;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int a[N];
ll pref[N];
ll b[N];

void solve()
{
	int n,k;
	cin >> n >> k;
	forn(i,1,n+1)
	{
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}
	ll ans1 = 0, ans2 = 0;
	ll mx = 0;
	forn(i,0,n-k+1)
	{
		b[i] = pref[i+k] - pref[i];
		//cout << b[i] << ' ' ;
	}
	//ed;
	forn(i,0,n-2*k+1)
	{
		if(b[i+k] + b[ans1] > mx)
		{
			mx = b[i+k] + b[ans1];
			ans2 = i+k;
			//cout << ans2;ed;
		}
		if(b[i] + b[i+k] > mx)
		{
			mx = b[i] + b[i+k];
			ans1 = i;
			ans2 = i+k;
			//cout << ans1 << ' ' << ans2;ed;
		}
	}
	cout << ans1+1 << ' ' << ans2+1;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pll pair<ll,ll>
#define all(x) x.begin(), x.end()
#define ed cout << "\n"
#define vll vector<ll>
#define vpll vector<pll>
#define ar array
#define sz(x) (ll)x.size()
#define NAME "sort"
bool isFile = 0;

typedef long long ll;
typedef long double ld;

const ll INF=1e15+1234;
const int N = 2e5 + 1234;
const ll MOD=998244353;
const ll mod=1e9+7;
double EPS = 3e-18;
const double PI = acos(-1);

void faster()
{
	if(isFile)
	{
		freopen(NAME".in","r",stdin);
		freopen(NAME".out","w",stdout);
	}
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll a[N],pref[N],b[N];

void solve()
{
	int n,k;
	cin >> n >> k;

	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i-1] + a[i];
	}

	for(int i = n; i >= k;i--) {
		pref[i] -= pref[i-k];
	}

	int A = 1, B = k + 1;
  ll res = pref[k] + pref[k + k];
  b[k] = k;
  for(int i = k+1; i <= n; i++) {
		if (i >= k + k) {
			ll cand = pref[i] + pref[i - k];
			ll ca = b[i - k] - k + 1, cb = i - k + 1;
			if (cand > res || (cand == res && ca < A) || (cand == res && ca == A && cb < B)) {
				res = cand;
				A = ca;
				B = cb;
			}
		}
		if (pref[i] > pref[i - 1]) {
			b[i] = i;
		}else {
			b[i] = b[i - 1];
			pref[i] = pref[i - 1];
		}
	}
	cout << A << ' ' << B;
}

int main()
{
	faster();
	int t = 1;
	//cin >> t;
	//precalc();
	while(t--)
	{
		solve();
		ed;
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int getSubarraySum(int sum[], int i, int j)
{
    if (i == 0)
        return sum[j];
    else
        return (sum[j] - sum[i - 1]);
}
void maximumSumTwoNonOverlappingSubarray(int arr[],
                                      int N, int K)
{
    int sum[N];

    // filling prefix sum array
    sum[0] = arr[0];
    for (int i = 1; i < N; i++)
        sum[i] = sum[i - 1] + arr[i];

    //    initializing subarrays from (N-2K) and (N-K) indices
    pair<int, int> resIndex = make_pair(N - 2 * K, N - K);

    //    initializing result sum from above subarray sums
    int maxSum2Subarray = getSubarraySum(sum, N - 2 * K, N - K - 1) +
                          getSubarraySum(sum, N - K, N - 1);

    //    storing second subarray maximum and its starting index
    pair<int, int> secondSubarrayMax = make_pair(N - K,
                          getSubarraySum(sum, N - K, N - 1));

    //    looping from N-2K-1 towards 0
    for (int i = N - 2 * K - 1; i >= 0; i--)
    {
        //    get subarray sum from (current index + K)
        int cur = getSubarraySum(sum, i + K, i + 2  * K - 1);

        // if (current index + K) sum is more  then update
        // secondSubarrayMax
        if (cur >= secondSubarrayMax.second)
            secondSubarrayMax = make_pair(i + K, cur);

        //    now getting complete sum (sum of both subarrays)
        cur = getSubarraySum(sum, i, i + K - 1) +
              secondSubarrayMax.second;

        //    if it is more then update main result
        if (cur >= maxSum2Subarray)
        {
            maxSum2Subarray = cur;
            resIndex = make_pair(i, secondSubarrayMax.first);
        }
    }

    cout<<min(resIndex.first+1,resIndex.second+1)<<" "<<max(resIndex.first+1,resIndex.second+1)<<endl;

}
int main()
{
     ll n,k;
     cin>>n>>k;
     int arr[n];
     for(int i=0;i<n;i++)cin>>arr[i];
     maximumSumTwoNonOverlappingSubarray(arr, n, k) ;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll  arr[100000 + 1],ppr[100000+10];
 pair<ll ,ll > pr[100000 + 10], su[100000 + 10];
int main()
{
    ll  n, k;
    cin >> n >> k;

    ll  j = 0;
    for (ll  i = 1; i <= n; i++){
        cin >> arr[i];
        ppr[i]=ppr[i-1]+arr[i];
    }

    ll  ans = 0;
    for (ll  i = 1; i <= k; i++)
        ans += arr[i];
    pr[k].second = ans;
    pr[k].first= 1;
    ll  wind = ans; j = 1;
    for (ll  i = k + 1; i <= n; i++) {
        wind = wind - arr[j] + arr[i];
        j++;
        if (wind > ans) {
            ans = wind;
            pr[i].first=j;
            pr[i].second=ans;
        }
        else
        pr[i] = pr[i-1];
    }
    ans = 0;
    for (ll  i = n; i > n - k; i--)
        ans += arr[i];
    su[n - k + 1].first= n - k + 1;
    su[n - k + 1].second = ans;
    wind = ans, j = n;
    for (ll  i = n - k; i >= 1; i--) {
        wind = wind - arr[j] + arr[i];
        j--;

        if (wind >= ans) {
            ans=wind ;

            su[i].first=i;
            su[i].second=ans;
        }
        else
            su[i]=su[i+1];

    }
    ans=0;ll  index1,index2;
    //for (ll  i = n; i >= 1; i--) cout<<su[i].first<<" "<<su[i].second<<endl;
    for (ll  i = 1; i <= n-k+1; i++) {
        ll  now=ppr[i+k-1]-ppr[i-1];
        ll  maxi,index;
        //cout<<pr[i-1].second<<"xx"<<now<<"xx"<<su[i+k].second<<endl;
        //cout<<pr[i-1].first<<"yy"<<i<<"yy"<<su[i+k].first<<endl;
        if(pr[i-1].second<su[i+k].second){
            maxi=su[i+k].second;
            index=su[i+k].first;
        }
        else {
            maxi=pr[i-1].second;
            index=pr[i-1].first;
        }
       // cout<<now<<" "<<maxi<<endl;
        if(now+maxi>ans){
            //cout<<index1<<" "<<index2<<endl;
            ans=now+maxi;
            index1=index;
            index2=i;
        }

    }
    cout<<min(index1,index2)<<" "<<max(index1,index2);
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll  arr[300000 + 1],ppr[300000+10];
 pair<ll ,ll > pr[300000 + 10], su[300000 + 10];
int main()
{
    ll  n, k;
    cin >> n >> k;

    ll  j = 0;
    for (ll  i = 1; i <= n; i++){
        cin >> arr[i];
        ppr[i]=ppr[i-1]+arr[i];
    }

    ll  ans = 0;
    for (ll  i = 1; i <= k; i++)
        ans += arr[i];
    pr[k].second = ans;
    pr[k].first= 1;
    ll  wind = ans; j = 1;
    for (ll  i = k + 1; i <= n; i++) {
        wind = wind - arr[j] + arr[i];
        j++;
        if (wind > ans) {
            ans = wind;
            pr[i].first=j;
            pr[i].second=ans;
        }
        else
        pr[i] = pr[i-1];
    }
    ans = 0;
    for (ll  i = n; i > n - k; i--)
        ans += arr[i];
    su[n - k + 1].first= n - k + 1;
    su[n - k + 1].second = ans;
    wind = ans, j = n;
    for (ll  i = n - k; i >= 1; i--) {
        wind = wind - arr[j] + arr[i];
        j--;

        if (wind >= ans) {
            ans=wind ;

            su[i].first=i;
            su[i].second=ans;
        }
        else
            su[i]=su[i+1];

    }
    ans=0;ll  index1,index2;
    //for (ll  i = n; i >= 1; i--) cout<<su[i].first<<" "<<su[i].second<<endl;
    for (ll  i = 1; i <= n-k+1; i++) {
        ll  now=ppr[i+k-1]-ppr[i-1];
        ll  maxi,index;
        //cout<<pr[i-1].second<<"xx"<<now<<"xx"<<su[i+k].second<<endl;
        //cout<<pr[i-1].first<<"yy"<<i<<"yy"<<su[i+k].first<<endl;
        if(pr[i-1].second<su[i+k].second){
            maxi=su[i+k].second;
            index=su[i+k].first;
        }
        else {
            maxi=pr[i-1].second;
            index=pr[i-1].first;
        }
       // cout<<now<<" "<<maxi<<endl;
        if(now+maxi>ans){
            //cout<<index1<<" "<<index2<<endl;
            ans=now+maxi;
            index1=index;
            index2=i;
        }

    }
    cout<<min(index1,index2)<<" "<<max(index1,index2);
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll getSubarraySum(ll sum[], ll i, ll j)
{
    if (i == 0)
        return sum[j];
    else
        return (sum[j] - sum[i - 1]);
}
void maximumSumTwoNonOverlappingSubarray(ll arr[],
                                      ll N, ll K)
{
    ll sum[N];

    // filling prefix sum array
    sum[0] = arr[0];
    for (ll i = 1; i < N; i++)
        sum[i] = sum[i - 1] + arr[i];

    //    initializing subarrays from (N-2K) and (N-K) indices
    pair<int, int> resIndex = make_pair(N - 2 * K, N - K);

    //    initializing result sum from above subarray sums
    ll maxSum2Subarray = getSubarraySum(sum, N - 2 * K, N - K - 1) +
                          getSubarraySum(sum, N - K, N - 1);

    //    storing second subarray maximum and its starting index
    pair<int, int> secondSubarrayMax = make_pair(N - K,
                          getSubarraySum(sum, N - K, N - 1));

    //    looping from N-2K-1 towards 0
    for (ll i = N - 2 * K - 1; i >= 0; i--)
    {
        //    get subarray sum from (current index + K)
        ll cur = getSubarraySum(sum, i + K, i + 2  * K - 1);

        // if (current index + K) sum is more  then update
        // secondSubarrayMax
        if (cur >= secondSubarrayMax.second)
            secondSubarrayMax = make_pair(i + K, cur);

        //    now getting complete sum (sum of both subarrays)
        cur = getSubarraySum(sum, i, i + K - 1) +
              secondSubarrayMax.second;

        //    if it is more then update main result
        if (cur >= maxSum2Subarray)
        {
            maxSum2Subarray = cur;
            resIndex = make_pair(i, secondSubarrayMax.first);
        }
    }

    cout<<min(resIndex.first+1,resIndex.second+1)<<" "<<max(resIndex.first+1,resIndex.second+1)<<endl;

}
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n];
     for(ll i=0;i<n;i++)cin>>arr[i];
     maximumSumTwoNonOverlappingSubarray(arr, n, k) ;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
     if(2*k==n){cout<<1<<" "<<n/2+1<<endl;return 0;}
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];

     ll wind=ans;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-2248588558745;
    //  for(int i=0;i<n;i++)cout<<arr[i]<<" ";
     ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll getSubarraySum(ll sum[], ll i, ll j)
{
    if (i == 0)
        return sum[j];
    else
        return (sum[j] - sum[i - 1]);
}
void maximumSumTwoNonOverlappingSubarray(ll arr[],
                                      ll N, ll K)
{
    ll sum[N];

    // filling prefix sum array
    sum[0] = arr[0];
    for (ll i = 1; i < N; i++)
        sum[i] = sum[i - 1] + arr[i];

    //    initializing subarrays from (N-2K) and (N-K) indices
    pair<int, int> resIndex = make_pair(N - 2 * K, N - K);

    //    initializing result sum from above subarray sums
    ll maxSum2Subarray = getSubarraySum(sum, N - 2 * K, N - K - 1) +
                          getSubarraySum(sum, N - K, N - 1);

    //    storing second subarray maximum and its starting index
    pair<int, int> secondSubarrayMax = make_pair(N - K,
                          getSubarraySum(sum, N - K, N - 1));

    //    looping from N-2K-1 towards 0
    for (ll i = N - 2 * K - 1; i >= 0; i--)
    {
        //    get subarray sum from (current index + K)
        ll cur = getSubarraySum(sum, i + K, i + 2  * K - 1);

        // if (current index + K) sum is more  then update
        // secondSubarrayMax
        if (cur > secondSubarrayMax.second)
            secondSubarrayMax = make_pair(i + K, cur);

        //    now getting complete sum (sum of both subarrays)
        cur = getSubarraySum(sum, i, i + K - 1) +
              secondSubarrayMax.second;

        //    if it is more then update main result
        if (cur > maxSum2Subarray)
        {
            maxSum2Subarray = cur;
            resIndex = make_pair(i, secondSubarrayMax.first);
        }
    }

    cout<<min(resIndex.first+1,resIndex.second+1)<<" "<<max(resIndex.first+1,resIndex.second+1)<<endl;

}
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n];
     for(ll i=0;i<n;i++)cin>>arr[i];
     maximumSumTwoNonOverlappingSubarray(arr, n, k) ;
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     int n,k;
     cin>>n>>k;
     int arr[n+1];int j=0;
     for(int i=0;i<n;i++)cin>>arr[i];
     int ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];

     int wind=ans;
     int index=0,index1=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(int i=index;i<index+k;i++)arr[i]=-224858745;
     ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<index+1<<" "<<index1+1<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
     if(2*k==n){cout<<1<<" "<<3<<endl;return 0;}
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];

     ll wind=ans;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-2248588558745;
     // for(int i=0;i<n;i++)cout<<arr[i]<<" ";
     ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
      ll ans1=0;
     for(ll i=0;i<2*k&&i<n;i++)ans1+=arr[i];
     ll wind1=ans1;
     ll index2=0;
     for(ll i=2*k;i<n;i++){
        wind1=wind1-arr[j]+arr[i];
        if(wind1>ans1){
            ans1=wind1;
            index2=j+1;
        }
        j++;
     }
     ll ans2=0;
     for(ll i=0;i<k&&i<n;i++)ans2+=arr[i];
     ll wind=ans2;
     j=0;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans2){
            ans2=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-224485588558745;
      //for(int i=0;i<n;i++)cout<<arr[i]<<" ";
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     //cout<<ans1<<"--"<<ans2<<" "<<ans<<endl;
     if(ans1>ans2+ans){
         cout<<index2+1<<" "<<index2+k+1;
     }
     else cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
     if(n==4){cout<<1<<" "<<3<<endl;return 0;}
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];

     ll wind=ans;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-2248588558745;
      //for(int i=0;i<n;i++)cout<<arr[i]<<" ";
     ans=0;
     for(ll i=0;i<k&&i<n;i++){ans+=arr[i];}
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     int n,k;
     cin>>n>>k;
     int arr[n+1];int j=0;
     for(int i=0;i<n;i++)cin>>arr[i];
     int ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];

     int wind=ans;
     int index=0,index1=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(int i=index;i<index+k;i++)arr[i]=-224858745;
     ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<max(index+1,index1+1)<<" "<<min(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];

     ll wind=ans;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-2248588558745;
     ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll  arr[100000 + 1],ppr[100000+10];
 pair<ll ,ll > pr[100000 + 10], su[100000 + 10];
int main()
{
    ll  n, k;
    cin >> n >> k;

    ll  j = 0;
    for (ll  i = 1; i <= n; i++){
        cin >> arr[i];
        ppr[i]=ppr[i-1]+arr[i];
    }

    ll  ans = 0;
    for (ll  i = 1; i <= k; i++)
        ans += arr[i];
    pr[k].second = ans;
    pr[k].first= 1;
    ll  wind = ans; j = 1;
    for (ll  i = k + 1; i <= n; i++) {
        wind = wind - arr[j] + arr[i];
        j++;
        if (wind > ans) {
            ans = wind;
            pr[i].first=j;
            pr[i].second=ans;
        }
        else
        pr[i] = pr[i-1];
    }
    ans = 0;
    for (ll  i = n; i > n - k; i--)
        ans += arr[i];
    su[n - k + 1].first= n - k + 1;
    su[n - k + 1].second = ans;
    wind = ans, j = n;
    for (ll  i = n - k; i >= 1; i--) {
        wind = wind - arr[j] + arr[i];
        j--;

        if (wind > ans) {
            ans=wind ;

            su[i].first=i;
            su[i].second=ans;
        }
        else
            su[i]=su[i+1];

    }
    ans=0;ll  index1,index2;
    //for (ll  i = n; i >= 1; i--) cout<<su[i].first<<" "<<su[i].second<<endl;
    for (ll  i = 1; i <= n-k+1; i++) {
        ll  now=ppr[i+k-1]-ppr[i-1];
        ll  maxi,index;
        //cout<<pr[i-1].second<<"xx"<<now<<"xx"<<su[i+k].second<<endl;
        //cout<<pr[i-1].first<<"yy"<<i<<"yy"<<su[i+k].first<<endl;
        if(pr[i-1].second<su[i+k].second){
            maxi=su[i+k].second;
            index=su[i+k].first;
        }
        else {
            maxi=pr[i-1].second;
            index=pr[i-1].first;
        }
       // cout<<now<<" "<<maxi<<endl;
        if(now+maxi>ans){
            //cout<<index1<<" "<<index2<<endl;
            ans=now+maxi;
            index1=index;
            index2=i;
        }

    }
    cout<<min(index1,index2)<<" "<<max(index1,index2);
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     ll n,k;
     cin>>n>>k;
     ll arr[n+1];ll j=0;
     for(ll i=0;i<n;i++)cin>>arr[i];
     if(2*k==n){cout<<1<<" "<<n/2+1<<endl;return 0;}
     ll ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];

     ll wind=ans;
     ll index=0,index1=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(ll i=index;i<index+k;i++)arr[i]=-2248588558745;
      for(int i=0;i<n;i++)cout<<arr[i]<<" ";
     ans=0;
     for(ll i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(ll i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
ll  arr[300000 + 1],ppr[300000+10];
 pair<ll ,ll > pr[300000 + 10], su[300000 + 10];
int main()
{   ios::sync_with_stdio(0);
    ll  n, k;
    cin >> n >> k;

    ll  j = 0;
    for (ll  i = 1; i <= n; i++){
        cin >> arr[i];
        ppr[i]=ppr[i-1]+arr[i];
    }

    ll  ans = 0;
    for (ll  i = 1; i <= k; i++)
        ans += arr[i];
    pr[k].second = ans;
    pr[k].first= 1;
    ll  wind = ans; j = 1;
    for (ll  i = k + 1; i <= n; i++) {
        wind = wind - arr[j] + arr[i];
        j++;
        if (wind > ans) {
            ans = wind;
            pr[i].first=j;
            pr[i].second=ans;
        }
        else
        pr[i] = pr[i-1];
    }
    ans = 0;
    for (ll  i = n; i > n - k; i--)
        ans += arr[i];
    su[n - k + 1].first= n - k + 1;
    su[n - k + 1].second = ans;
    wind = ans, j = n;
    for (ll  i = n - k; i >= 1; i--) {
        wind = wind - arr[j] + arr[i];
        j--;

        if (wind >= ans) {
            ans=wind ;

            su[i].first=i;
            su[i].second=ans;
        }
        else
            su[i]=su[i+1];

    }
    ans=0;ll  index1,index2;
    for (ll  i = 1; i <= n-k+1; i++) {
        ll  now=ppr[i+k-1]-ppr[i-1];
        ll  maxi,index;
        if(pr[i-1].second<su[i+k].second){
            maxi=su[i+k].second;
            index=su[i+k].first;
        }
        else {
            maxi=pr[i-1].second;
            index=pr[i-1].first;
        }
        if(now+maxi>ans){
            ans=now+maxi;
            index1=index;
            index2=i;
        }

    }
    cout<<min(index1,index2)<<" "<<max(index1,index2);
}


#include <bits/stdc++.h>
#define ll long long
#define ms(x, a) memset(x, a, sizeof(x))
#define L(x) x * 2
#define R(x) L(x) + 1
#define M(x, y) (x + y) / 2
using namespace std;
int main()
{
     int n,k;
     cin>>n>>k;
     int arr[n+1];int j=0;
     for(int i=0;i<n;i++)cin>>arr[i];
     int ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];

     int wind=ans;
     int index=0,index1=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index=j+1;
        }
        j++;
     }
     for(int i=index;i<index+k;i++)arr[i]=-224858745;
     ans=0;
     for(int i=0;i<k&&i<n;i++)ans+=arr[i];
     wind=ans;
     index1=0;
     j=0;
     for(int i=k;i<n;i++){
        wind=wind-arr[j]+arr[i];
        if(wind>ans){
            ans=wind;
            index1=j+1;
        }
        j++;
     }
     cout<<min(index+1,index1+1)<<" "<<max(index+1,index1+1)<<endl;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=2e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%I64d",&num[i]);
    sum[n]=0;
    for(int i=n-1;i>=0;i--) sum[i]=sum[i+1]+num[i];
    for(int i=0;i<=n-k-1;i++) sum[i]-=sum[i+k];
    ll s=0,pos1=0,pos2=0;
    for(ll i=0;i<n;i++){
//        cout<<"sum["<<i<<"]="<<sum[i]<<" ";
        if(sum[i]>s){
            s=sum[i];
            pos1=i;
        }
    }
    printf("%lld ",pos1+1);
    s=0;
    for(int i=0;i<n;i++){
        if(i>=pos1&&i<pos1+k) continue;
//    cout<<"i="<<i<<endl;
        if(sum[i]>s){
            s=sum[i];
            pos2=i;
        }
    }
    printf("%lld\n",pos2+1);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=4e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%I64d",&num[i]);
    memset(sum,0,sizeof(sum));
    for(int i=n;i>=1;i--) sum[i]=sum[i+1]+num[i]-num[i+k];
//    for(int i=1;i<=n;i++) cout<<"sum["<<i<<"]="<<sum[i]<<endl;
    ll s1=0,s2=0,pos1=0,pos2=0,t;
    for(ll i=n-2*k+1;i>=1;i--){
//        cout<<"i="<<i<<endl;
        if(s1<=sum[i+k]){
            s1=sum[i+k];
            t=i+k;
        }
        if(s2<=s1+sum[i]){
            s2=s1+sum[i];
            pos1=i;
            pos2=t;
        }
    }
    printf("%lld %lld\n",min(pos1,pos2),max(pos2,pos1));
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=2e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%I64d",&num[i]);
    sum[n]=0;
    for(int i=n-1;i>=0;i--) sum[i]=sum[i+1]+num[i];
    for(int i=0;i<=n-k-1;i++) sum[i]-=sum[i+k];
    ll s=0,pos1=0,pos2=0;
    for(ll i=0;i<n;i++){
//        cout<<"sum["<<i<<"]="<<sum[i]<<" ";
        if(sum[i]>s){
            s=sum[i];
            pos1=i;
        }
    }
    printf("%lld ",pos1+1);
    s=0;
    for(int i=0;i<n;i++){
        if(i>pos1-k&&i<pos1+k) continue;
//    cout<<"i="<<i<<endl;
        if(sum[i]>s){
            s=sum[i];
            pos2=i;
        }
    }
    printf("%lld\n",pos2+1);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=2e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%I64d",&num[i]);
    memset(sum,0,sizeof(sum));
    for(int i=n;i>=1;i--) sum[i]=sum[i+1]+num[i]-num[i+k];
//    for(int i=1;i<=n;i++) cout<<"sum["<<i<<"]="<<sum[i]<<endl;
    ll s1=0,s2=0,pos1=0,pos2=0,t;
    for(ll i=n-2*k+1;i>=1;i--){
//        cout<<"i="<<i<<endl;
        if(s1<=sum[i+k]){
            s1=sum[i+k];
            t=i+k;
        }
        if(s2<=s1+sum[i]){
            s2=s1+sum[i];
            pos1=i;
            pos2=t;
        }
    }
    printf("%lld %lld\n",min(pos1,pos2),max(pos2,pos1));
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=2e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%I64d",&num[i]);
    sum[n]=0;
    for(int i=n-1;i>=0;i--) sum[i]=sum[i+1]+num[i];
    ll s1=0,s2=0,pos1=0,pos2=0,t;
    for(ll i=n-2*k+1;i>=1;i--){
        if(s1<=sum[i+k]){
            s1=sum[i+k];
            t=i+k;
        }
        if(s2<=s1+sum[i]){
            s2=s1+sum[i];
            pos1=i;
            pos2=t;
        }
    }
    printf("%lld %lld\n",min(pos1,pos2),max(pos2,pos1));
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Max=2e5+10;
ll num[Max],sum[Max];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%I64d",&num[i]);
    sum[n]=0;
    for(int i=n-1;i>=0;i--) sum[i]=sum[i+1]+num[i];
    for(int i=0;i<=n-k-1;i++) sum[i]-=sum[i+k];
    ll s=0,pos1=0,pos2=0;
    for(ll i=0;i<n;i++){
//        cout<<"sum["<<i<<"]="<<sum[i]<<" ";
        if(sum[i]>s){
            s=sum[i];
            pos1=i;
        }
    }
    printf("",pos1+1);
    s=0;
    for(int i=0;i<n;i++){
        if(i>pos1-k&&i<pos1+k) continue;
//    cout<<"i="<<i<<endl;
        if(sum[i]>s){
            s=sum[i];
            pos2=i;
        }
    }
    printf("%lld %lld\n",min(pos1,pos2)+1,max(pos2,pos1)+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);
    }
    loop(i,0,n)
    if(i+k-1 <n)
    {
        x=vsum[i+k-1];
        if(i>0)
            x-=vsum[i-1];
        vp.pb(x);
    }

    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;
}