#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define rep(i, l, r) for (int i = l; i < (r); i++)
#define all(x) begin(x), end(x)
#define endl "\n"
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
template<class T> void out(T x) { cout << x << '\n'; }
template<class T> void out(vector<T> x) { for (int i = 0; i < sz(x); i++) cout << x[i] << " \n"[i == sz(x) - 1]; }
template<class T> void chmax(T &a, T x) {a = max(a, x);}
const ll inf = 1e13 + 100;
#include <atcoder/lazysegtree>
void solve(){
int n;cin >> n;
vi v(n);
rep(i, 0, n)cin >> v[i];
int j = -1;
rep(i, 0, n-1) {
if (v[i] > v[i+1]){j = i;break;}
}
if (j == -1) {cout << 1 << " " << 1 << endl; return;}
int l = j, r = j + 1;
while (l > 0 && v[l-1] >= v[l])l--;
while (r < n - 1 && v[r] >= v[r+1])r++;
reverse(v.begin()+l, v.begin() + r + 1);
rep(i, 0, n-1)if (v[i] > v[i+1]) {
cout << "impossible" << endl;
return;
}
cout << l+1 << " " << r+1 << endl;
}
int main() {
int T = 1;
while (T--)solve();
}