#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 *, long long);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, p = -1, i, x;
  long long c = 0;
  scanf("%d\n", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (x) {
      if (p >= 0)
        c *= (i - p);
      else
        c = 1;
      p = i;
    }
  }
  printf("%I64d", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <main+0x9c>
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11a9 <main+0x89>
cmpl   $0x0,-0xc(%rbp)
jl     119b <main+0x7b>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cltq
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11a3 <main+0x83>
movq   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11ae <main+0x8e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <main+0x35>
mov    -0x20(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    1192 <main+0x72>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
lea    0x4(%rsp),%r15
mov    $0x1,%r13d
xor    %r12d,%r12d
jmp    1169 <main+0x49>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    (%rsp),%ebx
jge    1195 <main+0x75>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
je     1160 <main+0x40>
movslq %ebp,%rax
mov    %rbx,%rcx
sub    %rax,%rcx
imul   %rcx,%r12
test   %eax,%eax
cmovs  %r13,%r12
mov    %ebx,%ebp
jmp    1160 <main+0x40>
xor    %r12d,%r12d
lea    0xe6b(%rip),%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%I64d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
store i32 0, i32* %1
store i32 -1, i32* %3
store i64 0, i64* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %8
8: ; preds = %30, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %3
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = load i64, i64* %6
%25 = mul nsw i64 %24, %23
store i64 %25, i64* %6
br label %27
26: ; preds = %16
store i64 1, i64* %6
br label %27
27: ; preds = %26, %19
%28 = load i32, i32* %4
store i32 %28, i32* %3
br label %29
29: ; preds = %27, %12
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %8
33: ; preds = %8
%34 = load i64, i64* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %34)
%36 = load i32, i32* %1
ret i32 %36
}

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