#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 *, long long *);
int main() {
  long long int n;
  while (1) {
    scanf("%lld", &n);
    if (!n)
      break;
    printf("%lld\n", (n * (n + 1) * (2 * n + 1)) / 6);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jne    114f <main+0x2f>
jmp    118d <main+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    -0x10(%rbp),%rcx
shl    $0x1,%rcx
add    $0x1,%rcx
imul   %rcx,%rax
mov    $0x6,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rax
test   %rax,%rax
je     119c <main+0x7c>
movabs $0x2aaaaaaaaaaaaaab,%r12
aa aa 2a
lea    0xeb4(%rip),%r14
lea    0xea8(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
lea    0x1(%rax),%rcx
imul   %rax,%rcx
add    %rax,%rax
add    $0x1,%rax
imul   %rcx,%rax
imul   %r12
mov    %rdx,%rsi
shr    $0x3f,%rsi
add    %rdx,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rax
test   %rax,%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
br label %3
3: ; preds = %0, %8
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%5 = load i64, i64* %2
%6 = icmp ne i64 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %3
br label %19
8: ; preds = %3
%9 = load i64, i64* %2
%10 = load i64, i64* %2
%11 = add nsw i64 %10, 1
%12 = mul nsw i64 %9, %11
%13 = load i64, i64* %2
%14 = mul nsw i64 2, %13
%15 = add nsw i64 %14, 1
%16 = mul nsw i64 %12, %15
%17 = sdiv i64 %16, 6
%18 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %3
19: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp eq i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %16, %6 ], [ %4, %0 ]
%8 = add nsw i64 %7, 1
%9 = mul nsw i64 %8, %7
%10 = shl nsw i64 %7, 1
%11 = or i64 %10, 1
%12 = mul nsw i64 %9, %11
%13 = sdiv i64 %12, 6
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%16 = load i64, i64* %1
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %6, %0
ret i32 0
}