#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 */
typedef int /*<<< orphan*/ tokenstring;
typedef int /*<<< orphan*/ numbercountline;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char numbercountline[10];
  int numbercount;
  fgets(numbercountline, sizeof(numbercountline), stdin);
  sscanf(numbercountline, "%d", &numbercount);
  char tokenstring[100000];
  fgets(tokenstring, sizeof(tokenstring), stdin);
  char seps[] = " ";
  char *token;
  int var;
  int input[numbercount];
  int i = 0;
  token = strtok(tokenstring, seps);
  while (token != NULL) {
    sscanf(token, "%d", &var);
    input[i++] = var;
    token = strtok(NULL, seps);
  }
  int j;
  int counter = 0;
  int c, d, t;
  for (c = 1; c <= numbercount - 1; c++) {
    d = c;
    while (d > 0 && input[d] < input[d - 1]) {
      t = input[d];
      input[d] = input[d - 1];
      input[d - 1] = t;
      d--;
      counter++;
    }
  }
  printf("%d\n", counter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x18720,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    %rax,-0x18710(%rbp)
mov    (%rax),%edx
lea    -0x1a(%rbp),%rdi
mov    %rdi,-0x18718(%rbp)
mov    $0xa,%esi
call   1040 <fgets@plt>
mov    -0x18718(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x18710(%rbp),%rax
mov    (%rax),%edx
lea    -0x186c0(%rbp),%rdi
mov    $0x186a0,%esi
call   1040 <fgets@plt>
movw   $0x20,-0x186c2(%rbp)
mov    -0x20(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x186e0(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x18708(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x186e8(%rbp)
movl   $0x0,-0x186ec(%rbp)
lea    -0x186c0(%rbp),%rdi
lea    -0x186c2(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x186d0(%rbp)
cmpq   $0x0,-0x186d0(%rbp)
je     1274 <main+0x134>
mov    -0x186d0(%rbp),%rdi
lea    0xdd8(%rip),%rsi
lea    -0x186d4(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x18708(%rbp),%rax
mov    -0x186d4(%rbp),%edx
mov    -0x186ec(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x186ec(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x186c2(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x186d0(%rbp)
jmp    120c <main+0xcc>
movl   $0x0,-0x186f4(%rbp)
movl   $0x1,-0x186f8(%rbp)
mov    -0x186f8(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     137a <main+0x23a>
mov    -0x186f8(%rbp),%eax
mov    %eax,-0x186fc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x186fc(%rbp)
mov    %al,-0x18719(%rbp)
jle    12e6 <main+0x1a6>
mov    -0x18708(%rbp),%rcx
movslq -0x186fc(%rbp),%rax
mov    (%rcx,%rax,4),%eax
mov    -0x186fc(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
setl   %al
mov    %al,-0x18719(%rbp)
mov    -0x18719(%rbp),%al
test   $0x1,%al
jne    12f9 <main+0x1b9>
jmp    1361 <main+0x221>
mov    -0x18708(%rbp),%rax
movslq -0x186fc(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    %ecx,-0x18700(%rbp)
mov    -0x186fc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
movslq -0x186fc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18700(%rbp),%edx
mov    -0x186fc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x186fc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x186fc(%rbp)
mov    -0x186f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186f4(%rbp)
jmp    12a8 <main+0x168>
jmp    1366 <main+0x226>
mov    -0x186f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x186f8(%rbp)
jmp    1288 <main+0x148>
mov    -0x186f4(%rbp),%esi
lea    0xc7e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x186e0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186c8,%rsp
mov    0x2e8d(%rip),%r14
mov    (%r14),%edx
lea    -0x4a(%rbp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <fgets@plt>
lea    0xe8a(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    (%r14),%edx
lea    -0x186f0(%rbp),%r14
mov    %r14,%rdi
mov    $0x186a0,%esi
call   1040 <fgets@plt>
mov    %rsp,-0x40(%rbp)
movw   $0x20,-0x2a(%rbp)
mov    -0x30(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x2a(%rbp),%rsi
mov    %r14,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     1208 <main+0xc8>
lea    0xe2d(%rip),%r14
lea    -0x34(%rbp),%r15
lea    -0x2a(%rbp),%r13
mov    %rbx,%r12
xchg   %ax,%ax
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <sscanf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,(%r12)
xor    %edi,%edi
mov    %r13,%rsi
call   1060 <strtok@plt>
add    $0x4,%r12
test   %rax,%rax
jne    11e0 <main+0xa0>
mov    -0x30(%rbp),%r8d
xor    %esi,%esi
cmp    $0x2,%r8d
jl     1260 <main+0x120>
xor    %esi,%esi
mov    $0x1,%r10d
jmp    1229 <main+0xe9>
xchg   %ax,%ax
add    $0x1,%r10d
cmp    %r8d,%r10d
je     1260 <main+0x120>
lea    (%rsi,%r10,1),%r9d
mov    %r10d,%eax
mov    (%rbx,%rax,4),%edi
mov    %r10d,%eax
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rax),%ecx
mov    (%rbx,%rcx,4),%edx
cmp    %edx,%edi
jge    1220 <main+0xe0>
mov    %eax,%eax
mov    %edx,(%rbx,%rax,4)
mov    %edi,(%rbx,%rcx,4)
add    $0x1,%esi
mov    %ecx,%eax
test   %ecx,%ecx
jne    1240 <main+0x100>
mov    %r9d,%esi
jmp    1220 <main+0xe0>
lea    0xd9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@__const.main.seps = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i32
%8 = alloca [100000 x i8]
%9 = alloca [2 x i8]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%21 = load i32, i32* @stdin
%22 = call i32 @fgets(i8* %20, i32 10, i32 %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%25 = getelementptr inbounds [100000 x i8], [100000 x i8]* %8, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 100000, i32 %26)
%28 = bitcast [2 x i8]* %9 to i8*
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %12
%32 = alloca i32, i64 %30
store i64 %30, i64* %13
store i32 0, i32* %14
%33 = getelementptr inbounds [100000 x i8], [100000 x i8]* %8, i64 0, i64 0
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%35 = call i8* @strtok(i8* %33, i8* %34)
store i8* %35, i8** %10
br label %36
36: ; preds = %39, %2
%37 = load i8*, i8** %10
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i8*, i8** %10
%41 = call i32 @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%42 = load i32, i32* %11
%43 = load i32, i32* %14
%44 = add nsw i32 %43, 1
store i32 %44, i32* %14
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i32, i32* %32, i64 %45
store i32 %42, i32* %46
%47 = getelementptr inbounds [2 x i8], [2 x i8]* %9, i64 0, i64 0
%48 = call i8* @strtok(i8* null, i8* %47)
store i8* %48, i8** %10
br label %36
49: ; preds = %36
store i32 0, i32* %16
store i32 1, i32* %17
br label %50
50: ; preds = %96, %49
%51 = load i32, i32* %17
%52 = load i32, i32* %7
%53 = sub nsw i32 %52, 1
%54 = icmp sle i32 %51, %53
br i1 %54, label %55, label %99
55: ; preds = %50
%56 = load i32, i32* %17
store i32 %56, i32* %18
br label %57
57: ; preds = %73, %55
%58 = load i32, i32* %18
%59 = icmp sgt i32 %58, 0
br i1 %59, label %60, label %71
60: ; preds = %57
%61 = load i32, i32* %18
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %32, i64 %62
%64 = load i32, i32* %63
%65 = load i32, i32* %18
%66 = sub nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %32, i64 %67
%69 = load i32, i32* %68
%70 = icmp slt i32 %64, %69
br label %71
71: ; preds = %60, %57
%72 = phi i1 [ false, %57 ], [ %70, %60 ]
br i1 %72, label %73, label %95
73: ; preds = %71
%74 = load i32, i32* %18
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %32, i64 %75
%77 = load i32, i32* %76
store i32 %77, i32* %19
%78 = load i32, i32* %18
%79 = sub nsw i32 %78, 1
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i32, i32* %32, i64 %80
%82 = load i32, i32* %81
%83 = load i32, i32* %18
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %32, i64 %84
store i32 %82, i32* %85
%86 = load i32, i32* %19
%87 = load i32, i32* %18
%88 = sub nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %32, i64 %89
store i32 %86, i32* %90
%91 = load i32, i32* %18
%92 = add nsw i32 %91, -1
store i32 %92, i32* %18
%93 = load i32, i32* %16
%94 = add nsw i32 %93, 1
store i32 %94, i32* %16
br label %57
95: ; preds = %71
br label %96
96: ; preds = %95
%97 = load i32, i32* %17
%98 = add nsw i32 %97, 1
store i32 %98, i32* %17
br label %50
99: ; preds = %50
%100 = load i32, i32* %16
%101 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %100)
store i32 0, i32* %3
%102 = load i8*, i8** %12
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca [100000 x i8]
%6 = alloca i16
%7 = alloca i32
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = bitcast i32* %4 to i8*
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %8, i32 10, i32 %10)
%12 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%13 = getelementptr inbounds [100000 x i8], [100000 x i8]* %5, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 100000, i32 %14)
%16 = bitcast i16* %6 to i8*
store i16 32, i16* %6
%17 = bitcast i32* %7 to i8*
%18 = load i32, i32* %4
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i32, i64 %19
%22 = call i8* @strtok(i8* %13, i8* %16)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %27, %2
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 1
br i1 %26, label %36, label %60
27: ; preds = %2, %27
%28 = phi i64 [ %32, %27 ], [ 0, %2 ]
%29 = phi i8* [ %34, %27 ], [ %22, %2 ]
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%31 = load i32, i32* %7
%32 = add nuw i64 %28, 1
%33 = getelementptr inbounds i32, i32* %21, i64 %28
store i32 %31, i32* %33
%34 = call i8* @strtok(i8* null, i8* %16)
%35 = icmp eq i8* %34, null
br i1 %35, label %24, label %27
36: ; preds = %24, %56
%37 = phi i32 [ %58, %56 ], [ 1, %24 ]
%38 = phi i32 [ %57, %56 ], [ 0, %24 ]
%39 = add i32 %38, %37
%40 = zext i32 %37 to i64
%41 = getelementptr inbounds i32, i32* %21, i64 %40
%42 = load i32, i32* %41
br label %43
43: ; preds = %36, %51
%44 = phi i32 [ %37, %36 ], [ %46, %51 ]
%45 = phi i32 [ %38, %36 ], [ %54, %51 ]
%46 = add nsw i32 %44, -1
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %21, i64 %47
%49 = load i32, i32* %48
%50 = icmp slt i32 %42, %49
br i1 %50, label %51, label %56
51: ; preds = %43
%52 = zext i32 %44 to i64
%53 = getelementptr inbounds i32, i32* %21, i64 %52
store i32 %49, i32* %53
store i32 %42, i32* %48
%54 = add i32 %45, 1
%55 = icmp eq i32 %54, %39
br i1 %55, label %56, label %43
56: ; preds = %43, %51
%57 = phi i32 [ %45, %43 ], [ %39, %51 ]
%58 = add nuw nsw i32 %37, 1
%59 = icmp eq i32 %58, %25
br i1 %59, label %60, label %36
60: ; preds = %56, %24
%61 = phi i32 [ 0, %24 ], [ %57, %56 ]
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %61)
ret i32 0
}