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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    11ae <main+0x8e>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
imul   $0x7,-0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
imul   $0x3,-0x10(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
imul   %rcx,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11b2 <main+0x92>
lea    0xeba(%rip),%r14
lea    0xeae(%rip),%r15
lea    0x8(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
lea    -0x8(,%rax,8),%rdx
ff
sub    %rcx,%rdx
add    $0xfffffffffffffffe,%rax
imul   %rcx,%rax
lea    (%rax,%rax,2),%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
add    %rax,%rcx
sar    %rcx
lea    (%rdx,%rcx,1),%rsi
add    $0x5,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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
%3 = alloca i64
store i32 0, i32* %1
br label %4
4: ; preds = %0, %9
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%6 = load i64, i64* %2
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %25
9: ; preds = %4
%10 = load i64, i64* %2
%11 = add nsw i64 %10, -1
store i64 %11, i64* %2
%12 = load i64, i64* %2
%13 = mul nsw i64 7, %12
%14 = load i64, i64* %2
%15 = mul nsw i64 3, %14
%16 = load i64, i64* %2
%17 = sub nsw i64 %16, 1
%18 = mul nsw i64 %15, %17
%19 = sdiv i64 %18, 2
%20 = add nsw i64 %13, %19
store i64 %20, i64* %3
%21 = load i64, i64* %3
%22 = add nsw i64 %21, 5
store i64 %22, i64* %3
%23 = load i64, i64* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %23)
br label %4
25: ; preds = %8
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 %20, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %18, %6 ], [ %4, %0 ]
%8 = add nsw i64 %7, -1
store i64 %8, i64* %1
%9 = mul nsw i64 %8, 7
%10 = mul nsw i64 %8, 3
%11 = add nsw i64 %7, -2
%12 = mul nsw i64 %10, %11
%13 = sdiv i64 %12, 2
%14 = add i64 %9, 5
%15 = add i64 %14, %13
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%18 = load i64, i64* %1
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %6
20: ; preds = %6, %0
ret i32 0
}