/**
 * Solution to Challenge Problem 1.
 * Author: Igor Naverniouk
 *
 * Input:
 *     The program expects the input in
 * the following format:
 * - the size of the array, n.
 * - n elements of the array.
 * All of these numbers are separated by whitespace.
 *
 * Output:
 *      besti and bestj printed on a line.
 *
 * Assumptions:
 *      The array contains at least one positive number.
 **/
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    // read the array's size
    int n;
    cin >> n;

    // create a vector to store the elements
    vector< int > a( n );

    // read the elements
    for( int i = 0; i < n; i++ ) cin >> a[i];

    // find besti and bestj
    int bestSum = -1, sum = 0;
    int besti = -1, bestj = -1, i = 0, j;
    for( j = 0; j < n; j++ )
    {
        sum += a[j];
        if( sum > bestSum ) { bestSum = sum; besti = i; bestj = j; }
        if( sum < 0 ) { sum = 0; i = j + 1; }
    }

    // print the answer
    printf( "%d %d\n", besti, bestj );

    // Program finished normally
    return 0;
}

/**
 * To compile the program, save it as "ch1.cpp" and type
 * g++ -Wall ch1.cpp
 * To run, type
 * ./a.out
 *
 * For the following input:
 * 10
 * 2 3 8 9 7 5 -1 8 0 -2
 * 0 0
 * 1 1
 * 0 1
 * 2 3
 * 5 7
 * 1 8
 * 0 9
 * this program will print
 * 2
 * 3
 * 5
 * 17
 * 12
 * 39
 * 39
 **/
