#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  long int n;
  scanf("%ld", &n);
  long int i;
  long long int a[n];
  long long int s = 0;
  for (i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    s = s + a[i];
  }
  for (i = 1; i <= n; ++i)
    s -= i;
  if (s == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11c9 <main+0xa9>
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rdx
add    (%rcx,%rdx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <main+0x59>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11ff <main+0xdf>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11d1 <main+0xb1>
cmpq   $0x0,-0x30(%rbp)
jne    121b <main+0xfb>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%rbx
mov    -0x30(%rbp),%rax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmpq   $0x0,-0x30(%rbp)
jle    11e0 <main+0xc0>
mov    %rbx,-0x38(%rbp)
lea    0xe93(%rip),%r15
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    (%r12,%rbx,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
add    (%r12,%r14,8),%r13
add    $0x1,%r14
mov    -0x30(%rbp),%rcx
add    $0x8,%rbx
cmp    %rcx,%r14
jl     1180 <main+0x60>
test   %rcx,%rcx
jle    11c5 <main+0xa5>
lea    -0x1(%rcx),%rax
lea    -0x2(%rcx),%rdx
mul    %rdx
shld   $0x3f,%rax,%rdx
add    %rcx,%rcx
sub    %rdx,%r13
sub    %rcx,%r13
add    $0x1,%r13
mov    -0x38(%rbp),%rbx
test   %r13,%r13
lea    0xe39(%rip),%rax
lea    0xe2f(%rip),%rdi
cmove  %rax,%rdi
jmp    11e7 <main+0xc7>
lea    0xe25(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [5 x i8] c"YES\0A\00"
@.str.3 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i64, i64 %8
store i64 %8, i64* %5
store i64 0, i64* %6
store i64 0, i64* %3
br label %11
11: ; preds = %24, %0
%12 = load i64, i64* %3
%13 = load i64, i64* %2
%14 = icmp slt i64 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i64, i64* %3
%17 = getelementptr inbounds i64, i64* %10, i64 %16
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %17)
%19 = load i64, i64* %6
%20 = load i64, i64* %3
%21 = getelementptr inbounds i64, i64* %10, i64 %20
%22 = load i64, i64* %21
%23 = add nsw i64 %19, %22
store i64 %23, i64* %6
br label %24
24: ; preds = %15
%25 = load i64, i64* %3
%26 = add nsw i64 %25, 1
store i64 %26, i64* %3
br label %11
27: ; preds = %11
store i64 1, i64* %3
br label %28
28: ; preds = %36, %27
%29 = load i64, i64* %3
%30 = load i64, i64* %2
%31 = icmp sle i64 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = load i64, i64* %3
%34 = load i64, i64* %6
%35 = sub nsw i64 %34, %33
store i64 %35, i64* %6
br label %36
36: ; preds = %32
%37 = load i64, i64* %3
%38 = add nsw i64 %37, 1
store i64 %38, i64* %3
br label %28
39: ; preds = %28
%40 = load i64, i64* %6
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %46
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
store i32 0, i32* %1
%47 = load i8*, i8** %4
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%lld\00"
@str = [3 x i8] c"NO\00"
@str.4 = [4 x i8] c"YES\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = call i8* @llvm.stacksave()
%6 = alloca i64, i64 %4
%7 = load i64, i64* %1
%8 = icmp sgt i64 %7, 0
br i1 %8, label %23, label %37
9: ; preds = %23
%10 = icmp slt i64 %31, 1
br i1 %10, label %33, label %11
11: ; preds = %9
%12 = add nsw i64 %31, -1
%13 = zext i64 %12 to i65
%14 = add nsw i64 %31, -2
%15 = zext i64 %14 to i65
%16 = mul i65 %13, %15
%17 = lshr i65 %16, 1
%18 = trunc i65 %17 to i64
%19 = mul i64 %31, -2
%20 = add i64 %29, 1
%21 = sub i64 %20, %18
%22 = add i64 %19, %21
br label %33
23: ; preds = %0, %23
%24 = phi i64 [ %29, %23 ], [ 0, %0 ]
%25 = phi i64 [ %30, %23 ], [ 0, %0 ]
%26 = getelementptr inbounds i64, i64* %6, i64 %25
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %26)
%28 = load i64, i64* %26
%29 = add nsw i64 %28, %24
%30 = add nuw nsw i64 %25, 1
%31 = load i64, i64* %1
%32 = icmp slt i64 %30, %31
br i1 %32, label %23, label %9
33: ; preds = %11, %9
%34 = phi i64 [ %29, %9 ], [ %22, %11 ]
%35 = icmp eq i64 %34, 0
%36 = select i1 %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0)
br label %37
37: ; preds = %33, %0
%38 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), %0 ], [ %36, %33 ]
%39 = call i32 @puts(i8* dereferenceable(1) %38)
ret i32 0
}