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

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define chk(a) rep(i, a.size()) cout << a[i] << " "
#define SORT(c) sort((c).begin(),(c).end())
#define ll long long
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)


using namespace std;
typedef pair<int, int> pii;
#define WARU 1000000007;

int dx[] = { 0,1,0,1 };
int dy[] = { 0,0,1,1 };

int main(void) {
	//int w, h;
	//cin >> w >> h;

	//vector<int> p(w);
	//rep(i, w)
	//	cin >> p[i];
	//vector<int> q(h);
	//rep(i, h)
	//	cin >> q[i];

	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n)
		cin >> v[i];
	int res = 0;
	int piv = 1;
	int localmin = 1;
	res = v[0] - 1;
	v[0] = 1;
	while (piv < n) {
		int price = localmin + 1;
		//cout << piv << ":" << res << "," << price << endl;
		//rep(i, n)
		//	cout << v[i] << " ";
		//cout << endl;
		if (v[piv] <= price) {
			localmin = max(localmin, v[piv]);
			piv++;
			continue;
		}
		if (v[piv] > price * 2) {
			if (v[piv] % price == 0) {
				res += (v[piv] / price - 1);
				v[piv] = 1;
			}
			else {
				res += v[piv] / price;
				v[piv] = 1;
			}
			localmin = max(localmin, v[piv]);
			piv++;
		}
		else {
			res++;
			v[piv] = 1;
		}
	}
	cout << res << endl;
	
	return 0;
}