#include <bits/stdc++.h>
using namespace std;
#define int long long
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void ELA7MOSE()
{
    int n, mx = LLONG_MIN, tl, tr, t = 0, l = 0, r = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > mx) mx = a[i], l = i + 1, r = i + 1;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == mx) {
            if (!t) tl = i + 1;
            tr = i + 1, t++;
        }
        if ((a[i] != mx || i == n - 1) && t) {
            if (abs(tr - tl) > abs(r - l)) l = tl, r = tr;
            t = 0;
        }
    }
    cout << mx << endl << l << " " << r;
}
signed main() {
    file();
    long long tc = 1;
    // cin >> tc;
    while (tc--) ELA7MOSE();
}