class node : def __init__(self): self.val=None self.sib=1 self.total=1 class sticks: def __init__(self,length): self.s=0 self.x=node() self.x.val=length def counting(self,n): if n.val==1 : #print("total=",n.total) if n.total > self.s : self.s=n.total else : d=self.divisors(n.val) for i in range(len(d)): d[i]=int(d[i]) n.total=n.total+(d[i]*n.sib) p=node() p.val=int(n.val/d[i]) p.total=n.total p.sib=d[i]*n.sib #print("siblings",p.sib) self.counting(p) n.total=n.total-(d[i]*n.sib) def divisors(self,w): d=[] for i in range(2,w+1): if w%i == 0: d.append(i) return d def bigdivisor(self,n): if n==1 : return 1 k=n-1 for i in range(n): if n%k == 0 : return k k=k-1 def go(self,x,i): if x==1 : return #print("x=",x) d=self.bigdivisor(x) if d!=1 : self.sumlist[i]=self.sumlist[i]+d for j in range(d): q=int(x/d) self.go(q,i) if d==1 : self.sumlist[i]=self.sumlist[i]+x def main(): n=int(input()) sumlist=[1 for i in range(n)] arr=input() arr=arr.split() for i in range(len(arr)): arr[i]=int(arr[i]) for i in range(n): b=sticks(arr[i]) b.counting(b.x) sumlist[i]=b.s s=0 for i in range(n): s=s+int(sumlist[i]) print (s) if __name__=='__main__': main()