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: Accepted)

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long max_size = 0;

void dump(const char *label, const vector<long>& v)
{
    cout << label << ": ";
    for (auto i = v.begin(); i != v.end(); ++i) cout << (*i) << " ";
    cout << endl;
}

void trace(vector<long>& A, vector<long>& order)
{
    long max = *max_element(A.begin(), A.end());
    bool stop = true;
    for (long p = 1; p < max; ++p) {
        for (int i = 0; i < A.size(); ++i) {
            if (A[i] == p) break;
            if (A[i] > p) {
                stop = false;
                A[i] -= p;
                order.push_back(p);
                trace(A, order);
                order.pop_back();
                A[i] += p;
                break;
            }
        }
    }
    if (stop) {
        if (order.size() > max_size) {
            max_size = order.size();
            dump("save - A", A);
            dump("save - order", order);
        }
    }
}

long d(const vector<long>& A)
{
    long num = 0;
    long min = 1;
    for (size_t i = 0; i < A.size(); ++i) {
        if (A[i] == min) {
            ++min;
        } else if (A[i] > min) {
            auto n = (A[i]-1) / min; 
            // for (int i = 0; i < n; ++i) cout << min << " ";
            if (min == 1) ++min;
            num += n;
        }
    }
    // cout << endl;
    return num;
}

int main()
{
    int N;
    cin >> N;
    vector<long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << d(A) << endl;
    /*
    vector<long> order;
    trace(A, order);
    cout << max_size << endl;
    */
    return 0;
}