#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 *, ...);
int main() {
  int d, N;
  scanf("%d%d", &d, &N);
  int arr[100];
  for (int j = 0; j < d; j++) {
    scanf("%d", &arr[j]);
  }
  for (int k = d; k <= N; k++) {
    arr[k] = 0;
    for (int m = k - 1; m >= k - d; m--) {
      arr[k] = arr[k] + arr[m];
    }
  }
  printf("%d", arr[N]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1198 <main+0x78>
movslq -0x1a4(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1152 <main+0x32>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     123f <main+0x11f>
movslq -0x1a8(%rbp),%rax
movl   $0x0,-0x1a0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1ac(%rbp)
mov    -0x1ac(%rbp),%eax
mov    -0x1a8(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jl     1226 <main+0x106>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1ac(%rbp),%rax
add    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1ac(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1ac(%rbp)
jmp    11d1 <main+0xb1>
jmp    122b <main+0x10b>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11a1 <main+0x81>
movslq -0xc(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdb1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    117f <main+0x5f>
lea    0x10(%rsp),%r15
lea    0xeaa(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1160 <main+0x40>
movslq 0xc(%rsp),%r8
cmp    %r8d,%eax
jle    11a9 <main+0x89>
mov    0x10(%rsp,%r8,4),%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
movslq %eax,%r9
lea    0x1(%r8),%esi
mov    %r9,%rbx
jmp    11c8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %ebx,%esi
je     1189 <main+0x69>
movl   $0x0,0x10(%rsp,%rbx,4)
test   %eax,%eax
jle    11c0 <main+0xa0>
mov    %rbx,%rdi
sub    %r9,%rdi
xor    %ecx,%ecx
mov    %rbx,%rdx
nop
add    0xc(%rsp,%rdx,4),%ecx
add    $0xffffffffffffffff,%rdx
mov    %ecx,0x10(%rsp,%rbx,4)
cmp    %rdi,%rdx
jg     11e0 <main+0xc0>
jmp    11c0 <main+0xa0>

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
store i32 0, i32* %5
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %5
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %15
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
br label %18
18: ; preds = %13
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %9
21: ; preds = %9
%22 = load i32, i32* %2
store i32 %22, i32* %6
br label %23
23: ; preds = %56, %21
%24 = load i32, i32* %6
%25 = load i32, i32* %3
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %59
27: ; preds = %23
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %29
store i32 0, i32* %30
%31 = load i32, i32* %6
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %7
br label %33
33: ; preds = %52, %27
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = load i32, i32* %2
%37 = sub nsw i32 %35, %36
%38 = icmp sge i32 %34, %37
br i1 %38, label %39, label %55
39: ; preds = %33
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = add nsw i32 %43, %47
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %50
store i32 %48, i32* %51
br label %52
52: ; preds = %39
%53 = load i32, i32* %7
%54 = add nsw i32 %53, -1
store i32 %54, i32* %7
br label %33
55: ; preds = %33
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %23
59: ; preds = %23
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %61
%63 = load i32, i32* %62
%64 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %63)
ret i32 0
}

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