#include <stdio.h>
#include<stdlib.h>
 struct node {
     int val;
     struct Node* left;
     struct Node * right;
 };
 struct Node* insert(struct Node* root, int val){
     if (root == NULL){
     struct Node* node = (struct Node*)malloc(sizeof(struct Node));
     node->val = val;
     node->left = node->right = NULL;
     return node;
 }
  if (val < root->val)
  root->left = insert(root->left,val);
  else
  root->right = insert(root->right,val);
  return root;
 }
  void printLeafNodes(struct Node* root){
      if (root == NULL)
      return;
      printLeafNodes(root->left);
      pintfLeafNodes(root->right);
      if (root->left == NULL && root->right == NULL)
       printf("%d",root->val);
  }
  int main (){
      int n,val;
      scanf("%d",&n);
      
      if (n<=0){
          printf("Invalid input");
          return 0;
      }
      struct Node* root = NULL;
      for (int i=0;i<n;++i){
          scanf("%d",&val);
          root = insert(root,val);
      }
      printLeafNode(root);
      return 0;
  }