Problem:
Score : 300 points

Problem Statement

Given is a sequence of integers A_1, A_2, ..., A_N.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

2 ≤ N ≤ 200000

1 ≤ A_i ≤ 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

#include <stdio.h>
#include <stdlib.h>

int sort_DP ( int n , int *a , int *flag );
int find_func ( int n , int *a , int *flag );


int main ( void ){
  int n;
  int *a;
  int hoge,piyo;
  int *flag;
  *flag = 0;

  flag  = malloc ( sizeof( int ) );

  scanf("%d\n",&n);

  a = calloc ( n , sizeof ( int ));
  for ( hoge = 0 ; hoge < n ; hoge++ ){
    scanf("%d ",&a[hoge]);
  }

  sort_DP ( n , a , flag );
  find_func ( n , a , flag );
  //
  // printf("ojeigo\n");
  // for ( hoge = 0 ; hoge < n ; hoge++ )
  //   printf("%d\n",a[hoge]);

  if ( *flag == 1 ) printf("NO");
  else printf("YES");
  return 0;
}

int sort_DP ( int n , int *a , int *flag ){
  int *big_a,*small_a;
  int big_n = 0 ;
  int small_n = 0;
  int hoge;

  if ( n <= 1 )
    return 0;

  // for ( hoge = 0 ; hoge < n ; hoge++ )
  //   printf("%d ",a[hoge]);

  big_a = calloc ( n+1 , sizeof ( int ));
  small_a = calloc ( n+1 , sizeof ( int ));


  for ( hoge = 1 ; hoge < n ; hoge++ ){
    if ( a[hoge] == a[0] ){
      *flag = 1;
      return 0;
    }
    else {
      if ( a[hoge] < a[0] ){
        small_a[small_n] = a[hoge];
        small_n++;
      }
      else{
        big_a[big_n] = a[hoge];
        big_n++;
      }
    }
  }

  if ( small_n == 0 ){
    small_a[0] = a[0];
    small_n++;
  }
  else {
    if ( big_n == 0 ){
      big_a[0] = a[0];
      big_n++;
    }
    else {
      big_a[big_n] = a[0];
      big_n++;
    }
  }


  // printf("\n");
  // for ( hoge = 0 ; hoge < small_n ; hoge++ )
  //   printf("%d ",small_a[hoge]);
  // printf("small_n:%d\n",small_n);
  // for ( hoge = 0 ; hoge < big_n ; hoge++ )
  //   printf("%d ",big_a[hoge]);
  // printf("big_n;%d\n",big_n);


  sort_DP ( small_n , small_a , flag );
  sort_DP ( big_n , big_a , flag );


  for ( hoge = 0 ; hoge < small_n ; hoge++ )
    a[hoge] = small_a[hoge];
  for ( hoge = small_n ; hoge < n ; hoge++ )
    a[hoge] = big_a[hoge-small_n];

  free ( big_a );
  free ( small_a );

  return 0;
}
int find_func ( int n , int *a , int *flag ){
  int hoge;
  if ( a[0] == a[1] ){
    *flag = 1;
    return 0;
  }
  else {
    for ( hoge = 1 ; hoge < n-1 ; hoge++ ){
      if ( a[hoge] == a[hoge-1] || a[hoge] == a[hoge+1] ){
        *flag = 1;
        return 0;
      }
    }
  }
  return 0;
}