type Bool* = bool type Int* = int type Lint* = int64 type Char* = char type String* = string template exit* = quit 0 template make*[T]( body :untyped ) :T = block: proc f() :T = body f() proc less*[T1,T2]( x :T1; y :T2 ) :Bool = x < y proc more*[T1,T2]( x :T1; y :T2 ) :Bool = x > y proc add*[T1,T2]( x :T1; y :T2 ) :T1 = x + y proc mul*[T1,T2]( x :T1; y :T2 ) :T1 = x * y proc `max=`*[T]( x :var T; y :T ) = if x < y: x = y proc `min=`*[T]( x :var T; y :T ) = if x > y: x = y type Vect*[T] = seq[T] proc vect*[T]( n :Int ) :Vect[T] = newSeq[T](result, n) proc vect*[T]( t :iterator:T ) :Vect[T] = for x in t: result &= x proc vect*[T]( t :iterator:T; n :Int ) :Vect[T] = result = vect[T] n for (i, x) in t: result[i] = x iterator items*( n :Int ) :Int = for i in 0 ..< n: yield i proc contain*[T]( t :iterator:T; e :T) :Bool = for x in t: if e == x: return true return false proc read*( T :typedesc ) :T = proc getchar() :char {.header:"stdio.h",importc:"getchar_unlocked".} when T is Char: result = getchar() discard getchar() when T is String: result = "" while true: var c = getchar() if [' ', '\10', '\255'].contain c: break result.add c when T is (Int or Lint): var sign = 1 c = getchar() if c == '-': sign = -1 c = getchar() while '0' <= c and c <= '9': result *= 10 result += c.int - '0'.int c = getchar() result *= sign when T is tuple: for r in result.fields: r = r.type.read proc write*[T]( x :T ) = echo x proc read*( T :typedesc; n :Int ) :Vect[T] = result = vect[T] n for i in n: result[i] = T.read iterator filter*[T]( t :iterator:T; p:proc(x:T):Bool ) :T = for x in t: if x.p: yield x proc sum*[T]( t :Vect[T] ) :T = for x in t: result += x type Mint*[M :static[Int]] = distinct Int const Mod7* = 1000000007 const Mod9* = 1000000009 type Mint7* = Mint[Mod7] type Mint9* = Mint[Mod9] proc mint*[M :static[Int]]( n :Int ) :Mint[M] = result = Mint[M] n mod M if result.int < 0: result = Mint[M] result.int + M proc `$`*( m :Mint ) :string = $m.int proc `+`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int + n.int proc `-`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int - n.int proc `*`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = mint[M] m.int * n.int proc `/`*[I;M:static[Int]]( m:Mint[M]; n:I) :Mint[M] = result = m result /= n proc `+=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m + n proc `-=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m - n proc `*=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = m = m * n proc `/=`*[I;M:static[Int]]( m :var Mint[M]; n :I ) = var a = n.int b = M u = 1 v = 0 while b > 0: var t = a div b a -= t * b u -= t * v swap( a, b ) swap( u, v ) return m *= u proc fact*[I]( n :Int ) :I = var memo {.global.} :Vect[I] = @[1.I] if n >= memo.len: let m = memo.len memo.setLen n + 1 for i in m..n: memo[i] = memo[i-1] * i return memo[n] ####### main ########### let N = Int.read B = Int.read N S = B.sum for b in B: write S - (N - 1) * b #