import sequtils, math, strutils, algorithm

proc lcm(l, r: int): int =
  var
    a = l
    b = r
    c = 0
  if a < b: swap(a, b)
  while b > 0:
    c = a mod b
    a = b
    b = c
  return a

proc gcm(arg: openArray[int]): int =
  result = 1
  for i in arg:
    result *= i div lcm(result, i)

proc f(arg: openArray[int]; val: int): int =
  for i in arg:
    result += val mod i


discard stdin.readLine

var inputs = stdin.readLine.split.map(parseInt)

echo inputs.f(inputs.gcm - 1)

