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

const int MAXN = 200000;

int a[MAXN];

int main() {
    freopen("agro.in", "r", stdin);
    freopen("agro.out", "w", stdout);

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int st = 0;
    int fn = 0;
    for (int i = 0; i < n; i++) {
        int cur = 1;
        for (int j = i + 1; j < n; j++) {
            if (a[j] == a[j - 1]) {
                cur++;
                if (cur > 2) {
                    if (j - 1 - i > fn - st) {
                        st = i;
                        fn = j - 1;
                    }
                    break;
                }
            } else {
                cur = 1;
            }
        }
        if (cur < 3) {
            if (n - 1 - i > fn - st) {
                st = i;
                fn = n - 1;
            }
        }
    }

    cout << st + 1 << " " << fn + 1 << endl;
}