Problem:


Score : 700 points

Problem Statement

N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.

Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below.

At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins.

Mr. Takahashi can set the value of positive integer P independently at each step.

He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash.

Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.

Constraints

1 ≦ | N | ≦ 100000

1 ≦ A_i ≦ 10^9(1 ≦ i ≦ N)

All inputs are integers.

Input

Inputs are provided from Standard Inputs in the following form.

N
A_1
:
A_N

Output

Output an integer representing the maximum number of products Mr. Takahashi can sell.

Sample Input 1

3
3
2
5

Sample Output 1

3

As values of P, select in order 1, 4, 1.

Sample Input 2

15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9

Sample Output 2

18



Sample input:
3
3
2
5


Sample output:
3

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
cur=1
ans=a[0]-1
a[0]=1
for x in a:
	if x<=cur:
		pass
	elif x==cur+1:
		cur=x
	else:
		ans+=0--(x-cur-1)//(cur+1)
print(ans)

Submission status: Accepted

Solution code:
N, *A = map(int, open(0))

ans = A[0] - 1
cur = 2
for a in A[1:]:
    if a == cur:
        cur += 1
    else:
        ans += (a - 1) // cur

print(ans)

Submission status: Accepted

Solution code:
#01:17
n = int(input())
for i in range(n):
  a = int(input())
  if i == 0:
    ans = a - 1
    now = 2
    continue
  if a == now:
    now += 1
    #print(a,now,ans)
    continue
  ans += (a-1) // now
  #print(a,now,ans)
print(ans)

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [ir() for _ in range(N)]
answer = A[0] - 1
cur_limit = 2
for a in A[1:]:
    if a == cur_limit:
        cur_limit += 1
        continue
    answer += (a-1) // cur_limit

print(answer)
# 44

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [ir() for _ in range(N)]
answer = A[0] - 1
cur_limit = 2
for a in A[1:]:
    if a == cur_limit:
        cur_limit += 1
        continue
    answer += -((-(a-cur_limit)) // cur_limit)

print(answer)
# 44

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
now = 1
for _ in range(N):
    A = int(input())
    ans+=(A-1)//now
    r = (A-1)%now+1
    if r+1>now:
        if now == 1 or (A-1)//now == 0:
            now = r+1
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,  [input() for i in range(n)]))
ans = 0
for i in range(n):
	if i == 0:
		ans += a[i] - 1
		a[i] = 1
	else:
		if a[i - 1] + 1< a[i]:
			ans += (a[i] - 1) // (a[i - 1] + 1)
			a[i] = a[i - 1]
		else:
			a[i] = max(a[i - 1], a[i])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
now = 2
count = A[0]-1
for i in range(1,N):
    if A[i] == now:
        now += 1
    elif A[i]%now != 0:
        count += A[i]//now
    else:
        count += (A[i]-1)//now
print(count)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cnt = 2
ans = a[0]-1
for i in range(1,n):
  if a[i] == cnt:
    cnt += 1
  else:
    ans += (a[i]-1)//cnt
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    mi = 1
    ans = A[0] - 1 if A[0] != 1 else 0
    for a in A[1:]:
        if a <= mi + 1:
            mi = max(mi, a)
            continue
        ans += (a - 1) // (mi + 1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    mi = 0
    ans = 0
    for a in A:
        if a <= mi+1:
            mi = max(mi, a)
            continue
        ans += (a-1)//(mi+1)
        mi = max(mi, 1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

ans = A[0]-1
v = 2
for a in A[1:]:
    if a < v: continue
    if a == v:
        v += 1
        continue
    ans += (a-1)//v
print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')

def main():
    N=I()
    A=LIN(N)
    now = 1
    ans = A[0]-1
    for a in A[1:]:
        if a <= now + 1:
            now = max(a,now)
            continue
        ans += (a-1)//(now+1)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N): a.append(int(input()))
res = a[0] - 1
a[0] = 1
mx = 1
mxa = max(a)
for i in range(N - 1):
  mx = max(mx, a[i])
  t = (a[i + 1] - 1) // (mx + 1)
  ok = mx + 1
  ng = mxa
  while ng - ok > 1:
    m = (ok + ng) // 2
    if (a[i + 1] - 1) // m == t: ok = m
    else: ng = m
  if t > 0: a[i + 1] = 1
  res += t
  #print(res, mx)
  #print(a)
print(res)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
mx = 1
a = []
for _ in range(N): a.append(int(input()))
res = a[0] - 1
a[0] = 1
for i in range(1, N):
  ok = mx + 1
  ng = a[i]
  ch = (a[i] - 1) // (mx + 1)
  while ng - ok > 1:
    m = (ok + ng) // 2
    if (a[i] - 1) // m == ch:
      ok = m
    else: ng = m
  res += (a[i] - 1) // ok
  if (a[i] - 1) // ok: a[i] = 1
  mx = max(mx, a[i])
  #print(res, mx, a)
print(res)

Submission status: Accepted

Solution code:
N = int(input())
A = list(int(input())for _ in range(N))

P = 1
ans = A[0]-1
A[0] = 1
for i in range(N):
    ans += (A[i]-1)//P
    if A[i] == P:
        P += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = a[0] - 1
a[0] = 1
t = 1
for x in a:
  if x == t: t += 1
  if x < t: continue
  if x%t == 0:
    x -= t+1
    cnt += 1
  cnt += x//t
print(cnt)

Submission status: Accepted

Solution code:
"""
Greedyなのか？
よさそう→所持金として存在しない最小の整数を選んでく？
dicで管理かなぁ→X

シミュレーションは無理！
いくつ引けるか考える→一度処理したらもう使わない
よってO(N)!!

1 2 6 7 7 7 7 7 7 7
の時、3番目で3を使ってしまうのはもったいない！！
→最大化するためには大きい数字で小さい数字を使いたい

同じ数字が来た！→仕方ないので引き上げ
そうでない→ +1した数字を使ってずらす(そこの部分の答えは変わらない)

now の2倍+1以上→now以下にできる(1は除く) ansはA[i] // now

"""

N = int(input())

A = []

for i in range(N):

    a = int(input())
    A.append(a)

ans = 0
now = 1

for i in range(N):

    if now == 1:
        ans += A[i]-1
        now += 1

    elif now == A[i]:
        now += 1

    elif A[i] % now == 0:
        ans += A[i] // now - 1
    else:
        ans += A[i] // now

print (ans)

Submission status: Accepted

Solution code:
def examA():
    S = SI(); N = len(S)
    T = "CODEFESTIVAL2016"
    ans = 0
    for i in range(N):
        if S[i]!=T[i]:
            ans +=1
    print(ans)
    return

def examB():
    N, A, B = LI()
    S = SI()
    d = defaultdict(int)
    for s in S:
        if s=="a":
            if d["a"]+d["b"]<A+B:
                print("Yes")
                d[s] += 1
            else:
                print("No")
        elif s=="b":
            if d["a"]+d["b"]<A+B and d["b"]<B:
                print("Yes")
                d[s] += 1
            else:
                print("No")
        else:
            print("No")
    return

def examC():
    W, H = LI()
    P = [I() for _ in range(W)]; P.sort()
    Q = [I() for _ in range(H)]; Q.sort()
    dh = 0; dw = 0
    p = 0; q = 0
    ans = 0
    for i in range(H+W):
        if (q<H and p<W and P[p]<Q[q]) or not q<H:
            ans += P[p]*(H+1-dh)
            p +=1; dw +=1
        else:
            ans += Q[q]*(W+1-dw)
            q +=1; dh+=1
    print(ans)
    return

def examD():
    N = I()
    A = [I() for _ in range(N)]
    flag = 1
    ans = A[0]-1
    A[0] = 1
    for i in range(1,N):
        a = A[i]
        if a==flag+1:
            flag +=1
        ans += (a-1)//(1+flag)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 1e-9
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    a = A.pop(0)
    ans = a-1
    b = 2
    for a in A:
        if b == a:
            b += 1
        c = (a-1) // b
        ans += c
    return ans


def main():
    N = read_int()
    A = [read_int() for _ in range(N)]
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a0 = int(input())
    a.append(a0)
ans = 0
key = "b"
count = 1
m = 0
for i in range(n):
    if key == "a":
        if a[i] == count:
            count += 1
        elif a[i] > count:
            if a[i]%count == 0:
                ans += a[i]//count - 1
            else:
                ans += a[i]//count
    else:
        if i == 0:
            ans += a[i]-1
            count += 1
        else:
            if a[i] == 2:
                key = "a"
                count = 3
                m = 2
            else:
                if a[i]%2 == 0:
                    ans += a[i]//2-1
                else:
                    ans += a[i]//2
    #print(ans,count)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    ans = 0
    pre = 1
    for _ in range(II()):
        a = II()
        if pre > a:
            continue
        if a % pre:
            ans += a // pre
            continue
        if pre == a:
            pre += 1
            continue
        tmp = a // pre - 1
        ans += tmp
        if pre == 1:
            pre += 1
    print(ans)

    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

count = A[0] - 1
tmp = 2

for a in A[1:]:
    count += (a - 1) // tmp
    if tmp == a:
        tmp += 1

print (count)

Submission status: Accepted

Solution code:
# http://ymduu.hatenablog.com/entry/2019/08/28/201134

def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = [int(input()) for _ in range(N)]

    ret = A[0] - 1
    div = 2
    for x in A[1:]:
        if x == div:
            div += 1
            continue
        ret += (x - 1) // div
    print(ret)


if __name__ == '__main__':
    main()

# if x % div == 0:
#     ret += (x - div*2) // div + (div * 2 // (div+1))
#     # div未満を残せるので、次以降もdivが使える
# else:
#     ret += (x - 1) // div
#     # この方法だと、divに一致するものが来るまでは、div未満で抑えられる
# 結局ret += (x - 1) // div回数だけ増える
# div==xのときはどうしようもないので、div+1して避ける

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 0
if A[0]>1:
    cnt += A[0]-1
    A[0]=1
cur = 1
for i in range(1,N):
    if A[i]<=cur:continue
    if A[i]==cur+1:
        cur += 1
        continue
    a = A[i]
    n = (a-cur-2)//(cur+1)
    cnt += (n+1)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
cur = 1
for x in a:
	if x == cur:
		cur += 1
	else:
		ans += (x-1)//cur
		if cur == 1:
			cur += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[int(input()) for _ in range(n)]

    # 最初の人には1円で売る
    ans=A[0]-1
    p=2
    # 以降は残りの所持金をp-1にできるようにする
    # 所持金が元々 p の場合はどうしようもないので+1する
    for a in A[1:]:
        if(a<p): # 状況変化無し
            continue
        elif(a==p):
            p+=1
        else:
            ans+=(a-1)//p
    print(ans)
resolve()

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a=[int(input()) for _ in [0]*n]
    cnt=a[0]-1
    now=2
    for i in range(1,n):
        if a[i]==now:
            now+=1
        elif a[i]>now:
            cnt+=(a[i]-1)//now
    print(cnt)
main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ret = A[0] - 1
M = 2
for i in range(1, N) :
    if A[i] < M :
        continue
        
    if A[i] == M :
        M += 1
    else :
        ret += (A[i] - 1) // M
        
print(ret)

Submission status: Accepted

Solution code:
#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	ans = 0
	c = 1
	a = int(input())
	ans += a - 1
	for i in range(N - 1):
		a = int(input())
		if a == c + 1:
			c += 1
		elif a > c + 1:
			if (a - c - 1) % (c + 1) == 0:
				ans += (a - c - 1) // (c + 1)
			else:
				ans += (a - c - 1) // (c + 1) + 1
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0]-1
mi = 2
for a in A[1:]:
    if mi > a:
        continue
    elif mi == a:
        mi += 1
    else:
        ans += (a-1) // mi
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
"""
this is wrong answer!!
dp = [[[0, 0], [0, 0]] for _ in range(N)]
dp[0][0][0] = 2
dp[0][1][0] = 2
dp[0][0][1] = A[0]-1
dp[0][1][1] = A[0]-1
for i in range(1, N):
    for l in [0, 1]:
        remove = A[i] // dp[i-1][l][0]
        if A[i] % dp[i-1][l][0] == 0:
            if dp[i][1][1] < dp[i-1][l][1] + remove - 1:
                dp[i][1][1] = dp[i-1][l][1] + remove - 1
                dp[i][1][0] = dp[i-1][l][0] + 1
            if dp[i][0][1] < dp[i-1][l][1] + remove - 2:
                dp[i][0][1] = dp[i-1][l][1] + remove - 2
                dp[i][0][0] = dp[i-1][l][0]
        else:
            if dp[i][1][1] < dp[i-1][l][1] + remove:
                dp[i][1][1] = dp[i-1][l][1] + remove
                dp[i][1][0] = dp[i-1][l][0]
                dp[i][0][1] = dp[i][1][1]
                dp[i][0][0] = dp[i][1][0]
ans = max(dp[N-1][0][1], dp[N-1][1][1])
print(ans)
"""

p = 2
ans = A[0]-1
for i in range(1, N):
    if p == A[i]:
        p += 1
    else:
        if A[i] % p == 0:
            ans += A[i]//p-1
        else:
            ans += A[i]//p
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))

p = 2
ans = a[0] - 1
for i in range(1, N):
    if a[i] == p:
        p += 1
    ans += ((a[i]-1)//p)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
k = 2
ans = A[0] - 1
for i in range(1, N):
    if A[i] == k:
        k += 1
    elif A[i] > k:
        ans += (A[i] - 1) // k
print(ans)

Submission status: Accepted

Solution code:
#D問題
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
MAX = 1

for i in range(N):
    if i == 0:
        ans+=A[0]-1
        now = 2
    else:
        if A[i] == now:
            now+=1
            continue
        if A[i]%now == 0:
            ans+=(A[i]//now)-1
        else:
            ans+=A[i]//now
            
print(ans)

Submission status: Accepted

Solution code:
n,*a=map(int,open(0))
b,c=1,0
for i in a:
  c+=~-i//b*(i>b)
  b+=b<2or i==b
print(c)

Submission status: Accepted

Solution code:
n,*a=map(int,open(0))
b,c=1,0
for i in a:
  if i>b:
    c+=(i-1)//b
    b+=b<2
  elif i==b:
    b+=1
print(c)

Submission status: Accepted

Solution code:
n,*a=map(int,open(0))
b=c=0
for i in a:
  if b<1:
    c+=i-1
    b=2
  elif i>b:
    c+=(i-1)//b
  elif i==b:
    b+=1
print(c)

Submission status: Accepted

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    money = 0
    ans = 0
    for i in range(num):
        now_num = data[i]
        if money == 0:
            ans += now_num - 1
            money = 1
        else:
            if now_num > money + 1:
                kari = math.ceil((now_num - money - 1) / (money + 1))
                ans += kari
                now_num = money
            money = max(now_num, money)
        # print(money, ans)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = A[0] - 1
p = 2
for a in A[1:]:
    if a > p:
        ans += (a - 1) // p
    if a == p:
        p += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
P = 1

for i, a in enumerate(A):
    if i == 0:
        ans += (a - 1) // P
        P += 1
        continue

    if a < P:
        continue

    if a == P:
        P += 1
        continue

    ans += (a - 1) // P

print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
N=int(input())
A=[int(input()) for i in range(N)]

ans=0
ans+=(A[0]-1)

S=2
for i in range(1,N):
    if A[i]>=S+1:
        ans+=(A[i]-1)//S
    elif A[i]==S:
        S+=1
    elif A[i]<S:
        continue
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
x,r=0,0
for a in A:
    d=(a-1)//(x+1)
    if d==0:
        x=max(a,x)
    elif x==0:
        x=1
    r+=d
print(r)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]
#%%
last_n = 1
cnt = 0
for ind,a in enumerate(A):
    if(a==last_n):
        last_n += 1
        continue
    n = (a-1)//last_n
    if(ind==0):
        last_n += 1
    cnt += n
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in range(N)]

ans = A[0] - 1

nowMin = 1
for a in A[1:]:
    if a == nowMin + 1:
        nowMin = a
    else:
        q, r = divmod(a, nowMin + 1)
        if r == 0:
            q -= 1
        ans += q

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
now = 1
for i in a:
    if i == now:
        now += 1
    if i < now:
        continue
    if i%now == 0:
        ans += i//now-1
    else:
        ans +=  i//now
    if now == 1:
        now += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = []

for i in range(n):
    nums.append(getN())

cur_max = 1
ans = nums[0] - 1

for num in nums[1:]:
    if num <= cur_max:
        pass
    elif num == cur_max + 1:
        cur_max += 1
    else:
         ans += (num - cur_max - 2) // (cur_max + 1) + 1

    # print(num, cur_max, ans)

print(ans)
"""
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
1 1 4 1 5 9 2 6 5 3 5 8 9 7 9 (2)
1 1 1 1 5 9 2 6 5 3 5 8 9 7 9 (3)
1 1 1 1 1 9 2 6 5 3 5 8 9 7 9 (5)
1 1 1 1 1 1 2 6 5 3 5 8 9 7 9 (9)
1 1 1 1 1 1 2 2 5 3 5 8 9 7 9 (10)
1 1 1 1 1 1 2 2 2 3 5 8 9 7 9 (11)
1 1 1 1 1 1 2 2 2 3 1 1 1 1 1 (18)
"""

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#CODEFESTIVAL2016 qualB D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
tmp = 1
ans = a[0] - 1
for i in range(1,n):
    if a[i] == tmp + 1:
        tmp += 1
    elif a[i] == tmp:
        continue
    else:
        ans += math.ceil(a[i]/(tmp+1)) - 1
print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

a = [onem() for i in range(n)]

ans = a[0] - 1

i = 1
co = 2
while i != n:
    if a[i] == co:
        co += 1
        i += 1
    else:
        if a[i] > co:
            if a[i] % co == 0:
                ans += a[i]//co - 1
            else:
                ans += a[i]//co
        i += 1



print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [0] * N
Z = 0
cnt = 0
for i in range(N):
  a = int(input())
  if a > Z + 1:
    z = (a - 1) // (Z + 1)
    cnt += z
    a = 1
  Z = max(a, Z)
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(input()) for _ in range(N)]

p = 1
answer = 0
for a in A:
    if a == p:
        p += 1
        continue
    answer += (a-1)//p
    if p == 1:
        p += 1

print(answer)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(input()) for _ in range(N)]
max_rem=0
ans=0
for a in A:
    if a >= max_rem+2:
        h = max_rem+1
        if a%h == 0:
            ans += (a//h-1)
            if max_rem==0:
                max_rem=1
        else:
            ans += (a//h)
    else:
        max_rem = max(max_rem, a)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for _ in [0]*N]

ans = A[0]-1
m = 2
for a in A[1:]:
    if a==m: m+=1
    elif a>m: ans += a//m-(a%m==0)
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(input())for i in range(n)]
c=0
b=1
d=0
while c<n:
    if a[c]==b:
        b+=1
        c+=1
    else:
        if a[c]%b==0:
            d+=((a[c]-2-b)//b+1if b!=1 else a[c]-1)
            c+=1
            b+=(1 if b==1 else 0)
        else:
            d+=a[c]//b
            c+=1
print(d)

Submission status: Accepted

Solution code:
N = int(input())
p = 1
num = 0
for i in range(N):
    a = int(input())
    if i == 0:
        num += a - 1
    elif a == p + 1:
        p += 1
    elif a > p + 1:
        num += (a - 1) // (p + 1)

print(num)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = A[0] - 1
    mn = 2
    for a in A[1:]:
        use = (a - 1) // mn
        if use == 0:
            mn = max(mn, a+1)
        ans += use
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]

current = 2
count = A[0]-1
for i in range(1,N):
    if current==A[i]:
        current+=1
    else:
        count+=(A[i]-1)//current

print(count)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
A=[int(input()) for _ in range(n)]
ans=A[0]-1
cnt=2
for i,a in enumerate(A[1:]):
    if a<cnt:
        continue
    if a==cnt:
        cnt+=1
    else:
        ans+=(a-1)//cnt
print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
if N == 1:
    print(int(input()) - 1)
    sys.exit()

A = [int(sys.stdin.readline()) for _ in range(N)]
ans = A[0] - 1
i = 2

for a in A[1:]:
    if i == a:
        i += 1
        continue
    ans += (a-1)//i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a = a[::-1]

ans = 0
num = 1

while a:
    if a[-1] < num:
        del a[-1]
    elif a[-1] == num:
        num += 1
    elif a[-1] > num:
        if a[-1] % num == 0:
            ans += a[-1] // num - 1
            a[-1] = 1
        else:
            ans += a[-1] // num
            a[-1] = 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
Max=0
ans=0
for i in range(N):
  if Max+1<A[i]:
    if A[i]%(Max+1):
      ans+=A[i]//(Max+1)
      A[i]=1
    else:
      ans+=A[i]//(Max+1)-1
      A[i]=1
  Max=max(Max,A[i])
  
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
p = 2
ans = a[0]-1
for i in range(1,n):
  if a[i] > p: ans+= (a[i]-1)//p
  elif a[i] == p: p += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[int(input()) for i in range(N)]
t=1
ans=A[0]-1
A[0]=1
for i in range(1,N):
    if A[i]==t+1:
        t+=1
        continue
    if A[i]%(t+1)==0 and A[i]>(t+1):
        A[i]-=(t+2)
        ans+=1
    ans+=A[i]//(t+1)
    A[i]=A[i]-(A[i]//(t+1))*(t+1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
min_v = 1
ans = 0
for a in A:
    if a == min_v:
        min_v += 1
    elif a > min_v:
        d = (a-1)//min_v
        ans += d
        if a - d*min_v == min_v == 1:
            min_v += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = [int(input()) for i in range(N)]

ans = aa[0]-1
tmp = 2
for i in range(1,N):
	a = aa[i]
	if a > tmp:
		ans += (a-1)//tmp
	elif a == tmp:
		tmp += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

bottom = 2
res = a[0]-1

for i in range(1,n):
    if a[i] == bottom: bottom=a[i]+1
    b = (a[i] - 1) // bottom
    res += b


print(res)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(input()) for i in range(N)]
V = 1
ans = 0
for i in range(N):
    #print(V, ans)
    if(A[i] > V):
        t = (A[i]-1)//V
        ans += t
        A[i] -= V*t
        if(A[i]+1 > V):
            A[i] = 1
    V = max(V,A[i]+1)
    
print(ans)