#include<iostream>
#include<vector>
#include<functional>

using namespace std;

template<typename Type>
class BTree {

	static const int default_min_degree = 2;
	std::function<bool(Type,Type)> default_comparison = [](Type high, Type low){ return high >= low;};
	
	int min_degree;
	std::function<bool(Type,Type)> comparison;
	
public :
	
	class Node{
	public :
		bool leaf;
		int number_of_key;
		Node* parent;
		std::vector<Type> key;
		std::vector<Node*> children;
		
		
		Node(int min_degree) {
			parent = nullptr;
			init(min_degree);
		}
		
		Node(int min_degree, Node* par){
			parent = par;
			init(min_degree);
		}
		
		void init(int min_degree) {
			leaf = true;
			number_of_key = 0; 
			
			key.resize(min_degree * 2 - 1, 0);
			children.resize(min_degree * 2, nullptr);
		}
	};
	
	Node* root;
	
	
	BTree(){
		min_degree = default_min_degree;
		comparison = default_comparison;
		create();
	}
	
	BTree(int new_min_degree){
		min_degree = new_min_degree;
		comparison = default_comparison;
		create();
	}
	
	BTree(std::function<bool(Type,Type)> com){
		min_degree = default_min_degree;
		comparison = com;
		create();
	}
	
	
	BTree(int new_min_degree, std::function<bool(Type,Type)> com){
		min_degree = new_min_degree;
		comparison = com;
		create();
	}
	
	~BTree(){
		all_delete(root);
	}
	
	void all_delete(Node* node){
		
		if(!node->leaf) {
			for(int i = 0; i <= node->number_of_key; i++){
				all_delete(node->children[i]);
			}
		}
		
		delete node;
	}
	
	void create(){
		root = new Node(min_degree);
	}
	
	Node* search(Type k){
		return search(root, k);
	}
	
	Node* search(Node* node, Type key){
		if(node == nullptr) return nullptr;
		
		int index = 0;
		
		for(; index < node->number_of_key && !comparison(node->key[index], key); index++);
		
		if(index < node->number_of_key && comparison(node->key[index], key) && comparison(key, node->key[index])) {
			return node;
		} else if(node->leaf) {
			return nullptr;
		} else {
			return search(node->children[index], key);
		}
	}
	
	
	void split_child(Node* node, int index){
		Node *right_child = new Node(min_degree, node);
		Node *left_child = node->children[index];
		
		right_child->leaf =  left_child->leaf;
		right_child->number_of_key = min_degree - 1;
		
		for(int j = 0; j < min_degree - 1; j++){
			right_child->key[j] = left_child->key[j + min_degree];
		}
		
		if(!left_child->leaf) {
			
			for(int j = 0; j < min_degree; j++){
				right_child->children[j] = left_child->children[j + min_degree];
			}
			
		}
		
		left_child->number_of_key = min_degree - 1;
		
		for(int j = node->number_of_key; j > index; j--){
			node->children[j+1] = node->children[j];
		}
		
		node->children[index+1] = right_child;
		
		for(int j = node->number_of_key - 1; j >= index; j--){
			node->key[j+1] = node->key[j];
		}
		
		node->key[index] = left_child->key[min_degree-1];
		
		node->number_of_key++;
	}
	
	void insert_nonfull(Node* node, Type key){
		int index = node->number_of_key - 1;
		
		if(node->leaf) {
			
			for(; index >= 0 && !comparison(key, node->key[index]); index--){
				node->key[index+1] = node->key[index];
			}
			
			node->key[index+1] = key;
			node->number_of_key++;
		} else {
			for(; index >= 0 && !comparison(key, node->key[index]); index--);
			
			index++;
			
			if(node->children[index]->number_of_key == 2 * min_degree - 1) {
				split_child(node, index);
				
				if(!comparison(node->key[index], key)) index++;
			}
			
			insert_nonfull(node->children[index], key);
		}
	}
	
	void insert(Type key){
		// if(search(key) != nullptr) return ;
		
		Node* temp_root = root;
		if(root->number_of_key == 2 * min_degree - 1) {
			Node* new_node = new Node(min_degree);
			
			root = new_node;
			
			root->leaf = false;
			root->children[0] = temp_root;
			root->parent = new_node;
			
			
			
			split_child(root, 0);
			insert_nonfull(root, key);
		} else {
			insert_nonfull(root, key);
		}
	}
	
	void erase(Type key){
		erase(root, key);
		
		while(root->number_of_key == 0 && !root->leaf) {
			Node *temp = root;
			
			root = root->children[0];
			
			delete temp;
		}
	}
	
	void erase(Node* node, Type key){
		if(node == nullptr) return ;
		int index = 0;
		
		for(; index < node->number_of_key && !comparison(node->key[index], key); index++);

		
		if(index < node->number_of_key && comparison(node->key[index], key) && comparison(key, node->key[index])) {
			if(node->leaf) {
				for(int i = index; i + 1 < node->number_of_key; i++){
					node->key[i] = node->key[i + 1];
				}
				
				node->number_of_key--;
			} else {
				Node* child1 = node->children[index];
				Node* child2 = node->children[index+1];
				
				if(child1->number_of_key >= min_degree) {
					Node *maximum = child1;
					
					while(!maximum->leaf){
						maximum = maximum->children[maximum->number_of_key];
					}
					
					maximum->key[maximum->number_of_key-1];
					
					node->key[index] = maximum->key[maximum->number_of_key-1];
					erase(child1, node->key[index]);
				} else if(child2->number_of_key >= min_degree){
					Node *minimum = child2;
					
					while(!minimum->leaf){
						minimum = minimum->children[0];
					}
					
					minimum->key[0];
					
					node->key[index] = minimum->key[0];
					erase(child2, node->key[index]);
				} else {
					
					child1->key[min_degree - 1] = key;
					
					for(int i = min_degree; i < min_degree * 2 - 1; i++){
						child1->key[i] = child2->key[i - min_degree];
					}
					
					for(int i = min_degree; i < min_degree * 2; i++){
						child1->children[i] = child2->children[i - min_degree];
					}
					
					delete child2;
					
					child1->number_of_key = min_degree * 2 - 1;
					
					for(int i = index; i + 1 < node->number_of_key; i++){
						node->key[i] = node->key[i + 1];
					}
					for(int i = index+1; i < node->number_of_key; i++){
						node->children[i] = node->children[i + 1];
					}
					
					node->number_of_key--;
					
					erase(child1, key);
				}
			}
		} else if(node->leaf) {
			return ;
		} else {
		
			Node* child0 = nullptr;
			Node* child1 =  child1 = node->children[index];;
			Node* child2 = nullptr;
			
			if(index >= 1) child0 = node->children[index-1];
			if(index <= node->number_of_key) child1 = node->children[index];
			if(index + 1 <= node->number_of_key) child2 = node->children[index+1];
			
			if(child1 == nullptr) {
				return ;
			} else if(child1->number_of_key >= min_degree) {
				erase(child1, key);
			} else if(child0 != nullptr && child0->number_of_key >= min_degree){
				index--;
				
				for(int i = child1->number_of_key - 2; i >= 0; i--){
					child1->key[i+1] = child1->key[i];
				}
				for(int i = child1->number_of_key - 1; i >= 0; i--){
					child1->children[i+1] = child1->children[i];
				}
				
				child1->key[0] = node->key[index];
				child1->children[0] = child0->children[child0->number_of_key];
				
				node->key[index] = child0->key[child0->number_of_key-1];
				
				child0->number_of_key--;
				child1->number_of_key++;
				
				erase(child1, key);
			} else if(child2 != nullptr && child2->number_of_key >= min_degree){
			
				for(int i = child2->number_of_key - 2; i >= 0; i--){
					child2->key[i] = child2->key[i+1];
				}
				for(int i = child2->number_of_key - 1; i >= 0; i--){
					child2->children[i] = child2->children[i+1];
				}
				
				child1->key[child1->number_of_key] = node->key[index];
				child1->children[child1->number_of_key+1] = child2->children[0];
				
				
				node->key[index] = child2->key[0];
				
				child2->number_of_key--;
				child1->number_of_key++;
				
				erase(child1, key);
			} else if(child2 != nullptr){
					child1->key[min_degree - 1] = node->key[index];
					
					for(int i = min_degree; i < min_degree * 2 - 1; i++){
						child1->key[i] = child2->key[i - min_degree];
					}
					
					for(int i = min_degree; i < min_degree * 2; i++){
						child1->children[i] = child2->children[i - min_degree];
					}
					
					delete child2;
					
					child1->number_of_key = min_degree * 2 - 1;
					
					for(int i = index; i + 1 < node->number_of_key; i++){
						node->key[i] = node->key[i + 1];
					}
					
					for(int i = index + 1; i < node->number_of_key; i++){
						node->children[i] = node->children[i + 1];
					}
					
					node->number_of_key--;
					
					erase(child1, key);
			} else if(child0 != nullptr){
					index--;
					child0->key[min_degree - 1] = node->key[index];
					
					for(int i = min_degree; i < min_degree * 2 - 1; i++){
						child0->key[i] = child1->key[i - min_degree];
					}
					
					for(int i = min_degree; i < min_degree * 2; i++){
						child0->children[i] = child1->children[i - min_degree];
					}
					
					delete child1;
					
					child0->number_of_key = min_degree * 2 - 1;
					
					for(int i = index; i + 1 < node->number_of_key; i++){
						node->key[i] = node->key[i + 1];
					}
					
					for(int i = index + 1; i < node->number_of_key; i++){
						node->children[i] = node->children[i + 1];
					}
					node->number_of_key--;
					
					erase(child0, key);
			} else {
			}
		}
	}
};

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


signed main(){
	
	int N;
	BTree<int> bt(5);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		int A;
		cin>>A;
		
		if(bt.search(A) != nullptr) {
			cout<<"NO"<<endl;
			return 0;
		}
		
		bt.insert(A);
	}
	
	
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 7552