#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1000], n, max1 = 0, max2 = 0, k;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int i, j;
  for (i = 0, j = n - 1; i < n && j >= 0;) {
    if (i >= j) break;
    if (a[i] > a[j]) {
      if (a[i] > max1) max1 = a[i];
      if (max2 < a[j]) max2 = a[j];
      j--;
    } else {
      if (a[j] > max1) max1 = a[j];
      if (max2 < a[i]) max2 = a[i];
      i++;
    }
  }
  cout << i + 1 << " " << max2 << endl;
  return 0;
}
