#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 */
long F(long, long);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, long *, ...);
int main() {
  long int n, m, a[10000], i, j, sum = 0;
  scanf("%ld %ld", &n, &m);
  for (i = 0; i < n; i++)
    scanf("%ld", &a[i]);
  n = 0;
  while (n < i) {
    sum = sum + F(a[n], a[n]);
    n++;
  }
  m = sum % m;
  printf("%ld", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138c0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x138b8(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movq   $0x0,-0x138a8(%rbp)
mov    -0x138a8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11b9 <main+0x89>
mov    -0x138a8(%rbp),%rax
lea    -0x138a0(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x138a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138a8(%rbp)
jmp    116e <main+0x3e>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x138a8(%rbp),%rax
jge    1222 <main+0xf2>
mov    -0x138b8(%rbp),%rax
mov    %rax,-0x138c0(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x138a0(%rbp,%rax,8),%rdi
ff
mov    -0x10(%rbp),%rax
mov    -0x138a0(%rbp,%rax,8),%rsi
ff
call   1030 <F@plt>
mov    %rax,%rcx
mov    -0x138c0(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x138b8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <main+0x91>
mov    -0x138b8(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xdc6(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x138c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x13898,%rsp
lea    0xebb(%rip),%rdi
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,(%rsp)
jle    11c3 <main+0x93>
mov    $0xffffffffffffffff,%r15
lea    0x10(%rsp),%rbx
lea    0xe96(%rip),%r14
xchg   %ax,%ax
mov    %r15,%r12
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r15
add    $0x2,%r12
add    $0x8,%rbx
cmp    (%rsp),%r12
jl     1170 <main+0x40>
movq   $0x0,(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
xchg   %ax,%ax
mov    0x10(%rsp,%rax,8),%rdi
mov    %rdi,%rsi
call   1030 <F@plt>
add    %rax,%rbx
mov    (%rsp),%rcx
lea    0x1(%rcx),%rax
mov    %rax,(%rsp)
cmp    %r15,%rcx
jl     11a0 <main+0x70>
jmp    11cd <main+0x9d>
movq   $0x0,(%rsp)
xor    %ebx,%ebx
mov    0x8(%rsp),%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11e8 <main+0xb8>
mov    %rbx,%rax
cqto
idiv   %rcx
jmp    11ee <main+0xbe>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %rdx,0x8(%rsp)
lea    0xe0a(%rip),%rdi
mov    %rdx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x13898,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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