#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) {
  int n, isOk = 1;
  long long int c, s;
  scanf("%d", &n);
  long long int sumT = (n * (n + 1LL)) / 2;
  s = 0;
  while (n && isOk) {
    scanf("%lld", &c);
    s += c;
    if (s > sumT) {
      printf("NO");
      isOk = 0;
    }
    n--;
  }
  if (isOk) {
    if (s == sumT) {
      printf("YES");
    } else {
      printf("NO");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x29(%rbp)
je     1187 <main+0x67>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1197 <main+0x77>
jmp    11e4 <main+0xc4>
lea    0xe65(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jle    11d6 <main+0xb6>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x4e>
cmpl   $0x0,-0xc(%rbp)
je     121e <main+0xfe>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    120d <main+0xed>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1219 <main+0xf9>
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
jmp    121e <main+0xfe>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
xor    %ebx,%ebx
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
lea    0x1(%rax),%rcx
imul   %rax,%rcx
mov    %rcx,%r13
shr    $0x3f,%r13
add    %rcx,%r13
sar    %r13
test   %rax,%rax
je     11ab <main+0x8b>
lea    0xe9b(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xe94(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x8(%rsp),%rbx
cmp    %r13,%rbx
jg     11c0 <main+0xa0>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rsp)
cmp    %r13,%rbx
jg     11ab <main+0x8b>
test   %eax,%eax
jne    1180 <main+0x60>
cmp    %r13,%rbx
lea    0xe56(%rip),%rax
lea    0xe4c(%rip),%r14
cmove  %rax,%r14
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [3 x i8] c"NO\00"
@.str.3 = [4 x i8] c"YES\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = bitcast i32* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
%8 = add nsw i64 %7, 1
%9 = mul nsw i64 %8, %7
%10 = sdiv i64 %9, 2
%11 = icmp eq i32 %6, 0
br i1 %11, label %23, label %12
12: ; preds = %0, %18
%13 = phi i64 [ %16, %18 ], [ 0, %0 ]
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%15 = load i64, i64* %2
%16 = add nsw i64 %15, %13
%17 = icmp sgt i64 %16, %10
br i1 %17, label %27, label %18
18: ; preds = %12
%19 = load i32, i32* %1
%20 = add nsw i32 %19, -1
store i32 %20, i32* %1
%21 = icmp eq i32 %20, 0
%22 = or i1 %17, %21
br i1 %22, label %23, label %12
23: ; preds = %18, %0
%24 = phi i64 [ 0, %0 ], [ %16, %18 ]
%25 = icmp eq i64 %24, %10
%26 = select i1 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
br label %27
27: ; preds = %12, %23
%28 = phi i8* [ %26, %23 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %12 ]
%29 = call i32 @printf(i8* dereferenceable(1) %28)
ret i32 0
}