#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);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int n, i, t, ligadoAte, acumulado;
  ligadoAte = 0;
  acumulado = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t >= ligadoAte)
      acumulado += 10;
    else
      acumulado += t + 10 - ligadoAte;
    ligadoAte = t + 10;
  }
  printf("%d\n", acumulado);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b0 <main+0x90>
lea    0xe99(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     118a <main+0x6a>
mov    -0x18(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x79>
mov    -0x10(%rbp),%eax
add    $0xa,%eax
sub    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <main+0x34>
mov    -0x18(%rbp),%esi
lea    0xe49(%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    118b <main+0x6b>
xor    %r13d,%r13d
lea    0xeb6(%rip),%r14
lea    0x4(%rsp),%r15
mov    $0xa,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
lea    0xa(%rax),%ecx
mov    %ecx,%edx
sub    %ebx,%edx
cmp    %ebx,%eax
cmovge %r12d,%edx
add    %edx,%r13d
add    $0x1,%ebp
mov    %ecx,%ebx
cmp    (%rsp),%ebp
jl     1160 <main+0x40>
jmp    118e <main+0x6e>
xor    %r13d,%r13d
lea    0xe6e(%rip),%rdi
mov    %r13d,%esi
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 = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %30, %0
%9 = load i32, i32* %3
%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, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = icmp sge i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 10
store i32 %19, i32* %6
br label %27
20: ; preds = %12
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 10
%23 = load i32, i32* %5
%24 = sub nsw i32 %22, %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, %24
store i32 %26, i32* %6
br label %27
27: ; preds = %20, %17
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 10
store i32 %29, i32* %5
br label %30
30: ; preds = %27
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %8
33: ; preds = %8
%34 = load i32, i32* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\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 ([3 x i8], [3 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 %22
8: ; preds = %0, %8
%9 = phi i32 [ %18, %8 ], [ 0, %0 ]
%10 = phi i32 [ %15, %8 ], [ 0, %0 ]
%11 = phi i32 [ %19, %8 ], [ 0, %0 ]
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, %10
%15 = add nsw i32 %13, 10
%16 = sub nsw i32 %15, %10
%17 = select i1 %14, i32 %16, i32 10
%18 = add nsw i32 %17, %9
%19 = add nuw nsw i32 %11, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %19, %20
br i1 %21, label %8, label %22
22: ; preds = %8, %0
%23 = phi i32 [ 0, %0 ], [ %18, %8 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}