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

template<typename X, typename Y>
bool chmax(X& a, Y b) { return (a < b) ? a = b, 1 : 0; }

template<typename X, typename Y>
bool chmin(X& a, Y b) { return (a > b) ? a = b, 1 : 0; }

using ll = long long;
using ull = unsigned long long;

const ll BASE = 1e9+7;
const int N = 1e5+5;

int n, a[N];
ull P[N], H[N];

ull get_hash(int l, int r) {
    return H[r] - H[l - 1] * P[r - l + 1];
}

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    // Subtask 3: 0 <= a_i <= 1
    if (*max_element(a + 1, a + n + 1) == 1) {
        int cnt[2], last[2];
        for (int i = 1; i <= n; i++) {
            cnt[a[i]]++;
            last[a[i]] = i;
        }
        int best_pos = -1;
        if (cnt[0] > cnt[1]) best_pos = last[0];
        else if (cnt[0] < cnt[1]) best_pos = last[1];
        else best_pos = n;
        cout << best_pos << ' ' << best_pos << '\n';
        return;
    }
    P[0] = 1;
    for (int i = 1; i <= n; i++) {
        P[i] = P[i - 1] * BASE;
        H[i] = H[i - 1] * BASE + a[i];
    }
    int best_cnt = 0, best_len = 0, best_pos = -1;
    for (int L = 1; L <= n; L++) {
        unordered_map<ull, int> cnt, pos;
        for (int i = L; i <= n; i++) {
            ull h = get_hash(i - L + 1, i);
            cnt[h]++;
            pos[h] = i;
        }
        for (auto& [h, c] : cnt) {
            int p = pos[h];
            if (chmax(best_cnt, c)) best_len = L, best_pos = p;
            else if (best_cnt == c) {
                if (chmax(best_len, L)) best_pos = p;
                else if (best_len == L) chmax(best_pos, p);
            }
        }
    }
    cout << best_pos - best_len + 1 << ' ' <<  best_pos << '\n';
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    #define TASK "BAI4"
    if (fopen(TASK".INP", "r")) {
        freopen(TASK".INP", "r", stdin);
        freopen(TASK".OUT", "w", stdout);
    }

    int tests = 1; // cin >> tests;
    while (tests--) solve();

    #ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}