#include <bits/stdc++.h>
using namespace std;
struct node {
  int key;
  int ind;
  struct node *left;
  struct node *right;
  int height;
};
int height(struct node *N) {
  if (N == NULL) return 0;
  return N->height;
}
struct node *newNode(int key, int ind) {
  struct node *node = (struct node *)malloc(sizeof(struct node));
  node->key = key;
  node->left = NULL;
  node->right = NULL;
  node->height = 1;
  node->ind = ind;
  return (node);
}
struct node *rightRotate(struct node *y) {
  struct node *x = y->left;
  struct node *T2 = x->right;
  x->right = y;
  y->left = T2;
  y->height = max(height(y->left), height(y->right)) + 1;
  x->height = max(height(x->left), height(x->right)) + 1;
  return x;
}
struct node *leftRotate(struct node *x) {
  struct node *y = x->right;
  struct node *T2 = y->left;
  y->left = x;
  x->right = T2;
  x->height = max(height(x->left), height(x->right)) + 1;
  y->height = max(height(y->left), height(y->right)) + 1;
  return y;
}
int getBalance(struct node *N) {
  if (N == NULL) return 0;
  return height(N->left) - height(N->right);
}
struct node *insert(struct node *node, int key, int ind) {
  if (node == NULL) return (newNode(key, ind));
  if (key < node->key)
    node->left = insert(node->left, key, ind);
  else
    node->right = insert(node->right, key, ind);
  node->height = max(height(node->left), height(node->right)) + 1;
  int balance = getBalance(node);
  if (balance > 1 && key < node->left->key) return rightRotate(node);
  if (balance < -1 && key > node->right->key) return leftRotate(node);
  if (balance > 1 && key > node->left->key) {
    node->left = leftRotate(node->left);
    return rightRotate(node);
  }
  if (balance < -1 && key < node->right->key) {
    node->right = rightRotate(node->right);
    return leftRotate(node);
  }
  return node;
}
void preOrder(struct node *root) {
  if (root != NULL) {
    cout << root->key << " " << root->ind << endl;
    preOrder(root->left);
    preOrder(root->right);
  }
}
void sol(struct node *root) {
  struct node *last_node = root;
  struct node *myroot = root;
  while (myroot->right != NULL) {
    myroot = myroot->right;
    if (myroot->right != NULL) last_node = myroot;
  }
  cout << myroot->ind << " " << last_node->key << endl;
}
vector<pair<int, int> > vii;
int main() {
  struct node *root = NULL;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    vii.push_back(make_pair(x, i + 1));
  }
  sort(vii.begin(), vii.end());
  for (int i = 0; i < N; i++) root = insert(root, vii[i].first, vii[i].second);
  sol(root);
  return 0;
}
