#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
#include <climits>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
long long a[N], b[N];
long long calc(long long a, long long b, long long c) {
    return (-b - sqrtl((long double) b * b - (long double)4 * a * c)) / (2 * a);
}
long long get(long long v) {
    long long sum = 0;
    for (int i = 1; i <= n; i ++)
        b[i] = min(max(1ll * 0, calc(-3, 3, -1 - v + a[i])), a[i]), sum += b[i];
    return sum;
}
long long calc1(long long a, long long b) {
    return a - b * b * 3 + 3 * b - 1;
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++)
        scanf("%lld", &a[i]);
    long long l = LONG_LONG_MIN, r = LONG_LONG_MIN, s = LONG_LONG_MIN, mid = 0;
    while (l <= r) {
        if (get(mid =  (l +  r) / 2) >= k) l = mid +1, s = max(s, mid);
        else
            r = mid - 1;
    }
    long long delta = get(s) - k;
    for (int i = 1; i <= n && delta; i ++)
        while (b[i] && calc1(a[i], b[i]) == s)
            b[i] --, delta --;
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
long long a[N], b[N];
long long calc(long long a, long long b, long long c) {
    return (-b - sqrtl((long double) b * b - (long double)4 * a * c)) / (2 * a);
}
long long get(long long v) {
    long long sum = 0;
    for (int i = 1; i <= n; i ++)
        b[i] = min(max(1ll * 0, calc(-3, 3, -1 - v + a[i])), a[i]), sum += b[i];
    return sum;
}
long long calc1(long long a, long long b) {
    return a - b * b * 3 + 3 * b - 1;
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++)
        scanf("%lld", &a[i]);
    long long l = -1e18, r = 1e18, s = -1e18, mid = 0;
    while (l <= r) {
        if (get(mid =  (l +  r) / 2) >= k) l = mid +1, s = max(s, mid);
        else
            r = mid - 1;
    }
    long long delta = get(s) - k;
    for (int i = 1; i <= n && delta; i ++)
        while (b[i] && calc1(a[i], b[i]) == s)
            b[i] --, delta --;
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -1e20;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if (s + e < 0 && (s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.25) + 1;
            b[i] = min(b[i], a[i]);
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3e18 - 3e9;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if ((s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0) - 0.5);
            b[i] = max(0LL, min(b[i], a[i]));
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -1e20;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if (s + e < 0 && (s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.5) + 1;
            b[i] = min(b[i], a[i]);
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3e18 - 3e9;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if (s + e < 0 && (s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.5) + 1;
            b[i] = min(b[i], a[i]);
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3e18 - 3e9;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if ((s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.5);
            b[i] = max(0LL, min(b[i], a[i]));
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -1e20;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if (s + e < 0 && (s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.5) + 1;
            b[i] = max(0LL, min(b[i], a[i]));
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (k--)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3e18 - 3e9;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if ((s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3) - 0.5);
            b[i] = max(0LL, min(b[i], a[i]));
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3e18 - 3e9;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if ((s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.5) + 1;
            b[i] = max(0LL, min(b[i], a[i]));
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

long long getScore(long long aa, long long bb)
{
    return aa - 3 * bb * bb - 3 * bb;
}
void solve()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    vector<long long> b(n, 0);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long s = -3 * 2e10 - 3e10;
    long long e = 1e9;
    while (s <= e)
    {
        long long m = (s + e) / 2;
        if (s + e < 0 && (s + e) % 2 == -1)
            m--;
        long long cnt = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] < m)
            {
                b[i] = 0;
                continue;
            }
            b[i] = (long long)(sqrt((a[i] - m) / 3.0 + 0.25) - 0.25) + 1;
            b[i] = min(b[i], a[i]);
            while (b[i] < a[i] && a[i] - 3 * b[i] * b[i] - 3 * b[i] >= m)
                b[i]++;
            cnt += b[i];
        }
        //dbg(s, e, m, cnt, (s + e) % 2);
        if (s == e)
            break;
        if (cnt <= k)
        {
            e = m;
        }
        else
            s = m + 1;
    }
    long long cnt = 0;
    priority_queue<pair<long long, long long>> qq;
    for (int i = 0; i < n; i++)
    {
        cnt += b[i];
        if (a[i] > b[i])
            qq.push({getScore(a[i], b[i]), i});
    }
    while (cnt < k)
    {
        auto p = qq.top();
        qq.pop();
        b[p.second]++;
        cnt++;
        if (a[p.second] > b[p.second])
            qq.push({getScore(a[p.second], b[p.second]), p.second});
    }
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << b[i];
    }
    cout << "\n";
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
    }
    cout.flush();
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    long long tmp = max(0LL, (a - T - 1) / 3);
    int x = min(a, max(0, (int) sqrtl(tmp)));
    while (x < a && a - 3 * x * (long long) (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    double tmp = max(.0, (a - T - 1.0) / 3);
    int x = min(a, max(0, (int) sqrt(tmp) - 1));
    while (x < a && a - 3 * x * (long long) (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    long long tmp = max(0LL, (a - T - 1) / 3);
    int x = min(a, max(0, (int) sqrt(tmp)));
    while (x < a && a - 3 * (long long) x * (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    double tmp = max(.0, (a - T - 1.0) / 3);
    int x = min(a, max(0, (int) sqrt(tmp) - 2));
    while (x < a && a - 3 * x * (long long) (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    double tmp = max(0LL, (a - T - 1) / 3);
    int x = min(a, max(0, (int) sqrt(tmp)));
    while (x < a && a - 3 * x * (long long) (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int F(int a, long long T) {
    double tmp = max(0LL, (a - T - 1) / 3);
    int x = min(a, max(0, (int) sqrt(tmp) - 2));
    while (x < a && a - 3 * x * (long long) (x + 1) - 1 >= T) {
        ++x;
    }
    return x;
}

int main () {
    ios_base::sync_with_stdio(0);
//  freopen("_input.txt", "rt", stdin);
//  freopen("_output.txt", "wt", stdout);

    int n;
    long long k;
    cin >> n >> k;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    long long left = -inf64;
    long long right = inf64;
    while (left < right) {
        long long mid = (left + right + 1) / 2;
        long long sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += F(a[i], mid);
        }

        if (sum < k) {
            right = mid - 1;
        } else {
            left = mid;
        }
    }

    vector<int> lx(n);
    vector<int> rx(n);
    for (int i = 0; i < n; ++i) {
        lx[i] = F(a[i], left + 1);
        rx[i] = F(a[i], left);
    }

    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += lx[i];
    }

    vector<int> x(n);
    int add = k - sum;
    for (int i = 0; i < n; ++i) {
        x[i] = min(lx[i] + add, rx[i]);
        add = max(0, add - (rx[i] - lx[i]));
    }

    for (int i = 0; i < n; ++i) {
        cout << x[i] << (i + 1 < n ? ' ' : '\n');
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int inf = 1e9;
const ll inf_ll = 1e18;
#define all(x) (x).begin(), (x).end()
#define pb push_back

#ifndef LOCAL
#define debug(...)
#else
#include "../../debug.cpp"
#endif

const ll N = 1e5+5;
ll n, k;
ll a[N], p[N], b[N], c[N];

ll qry(int i, ll x) {
    return x*(a[i]-x*x);
}

ll ch(ll d) {
    ll r = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        if (k >= 0)
            x = p[i], y = a[i];
        else
            x = p[i], y = 0;
        while (x < y) {
            ll m = (x+y)/2;
            if (qry(i, p[i])-qry(i, m) < d)
                x = m+1;
            else y = m;
        }
        b[i] = x, r += abs(p[i]-x);
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = round(sqrt(double(a[i])/3));
        if (qry(i, p[i]) < qry(i, p[i]+1))
            p[i]++;
        if (qry(i, p[i]) < qry(i, p[i]-1))
            p[i]--;
        p[i] = max(0ll, min(p[i], a[i]));
        k -= p[i];
    }
    ll x = 0, y = 1e18;
    while (x < y) {
        ll m = (x+y)/2;
        debug(m, ch(m), k);
        if (ch(m) < abs(k))
            x = m+1;
        else y = m;
    }
    if (ch(x) != abs(k)) {
        for (int i = 0; i < n; i++)
            c[i] = b[i];
        ll r = abs(k)-ch(x-1);
        for (int i = 0; i < n; i++) {
            if (r == 0) break;
            if (c[i] != b[i])
                b[i] = c[i], r--;
        }
    }
    for (int i = 0; i < n; i++)
        cout << b[i] << " \n"[i == n-1];
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int inf = 1e9;
const ll inf_ll = 1e18;
#define all(x) (x).begin(), (x).end()
#define pb push_back

#ifndef LOCAL
#define debug(...)
#else
#include "../../debug.cpp"
#endif

const ll N = 1e5+5;
ll n, k;
ll a[N], p[N], b[N], c[N];

ll qry(int i, ll x) {
    return x*(a[i]-x*x);
}

ll ch(ll d) {
    ll r = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        if (k >= 0)
            x = 0, y = a[i]-p[i];
        else
            x = 0, y = p[i];
        while (x < y) {
            ll m = (x+y)/2;
            if (qry(i, p[i]+(m-1)*(k >= 0 ? 1 : -1))-qry(i, p[i]+m*(k >= 0 ? 1 : -1)) < d)
                x = m+1;
            else y = m;
        }
        b[i] = p[i]+x*(k >= 0 ? 1 : -1), r += x;
    }
    debug(d, p[1], b[1]);
    return r;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = round(sqrt(double(a[i])/3));
        if (qry(i, p[i]) < qry(i, p[i]+1))
            p[i]++;
        if (qry(i, p[i]) < qry(i, p[i]-1))
            p[i]--;
        p[i] = max(0ll, min(p[i], a[i]));
        k -= p[i];
    }
    ll x = 0, y = 1e18;
    while (x < y) {
        ll m = (x+y)/2;
        if (ch(m) < abs(k))
            x = m+1;
        else y = m;
    }
    debug(k);
    debug(ch(x), ch(x-1));
    ch(x);
    if (ch(x) != abs(k)) {
        for (int i = 0; i < n; i++)
            c[i] = b[i];
        ll r = abs(k)-ch(x-1);
        for (int i = 0; i < n; i++) {
            if (r == 0) break;
            if (c[i] != b[i])
                b[i] = c[i], r--;
        }
    }
    for (int i = 0; i < n; i++)
        cout << b[i] << " \n"[i == n-1];
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int inf = 1e9;
const ll inf_ll = 1e18;
#define all(x) (x).begin(), (x).end()
#define pb push_back

#ifndef LOCAL
#define debug(...)
#else
#include "../../debug.cpp"
#endif

const ll N = 1e5+5;
ll n, k;
ll a[N], p[N], b[N], c[N];

ll qry(ll i, ll x) {
    return x*(a[i]-x*x);
}

ll ch(ll d) {
    ll r = 0;
    for (ll i = 0; i < n; i++) {
        ll x, y;
        if (k >= 0)
            x = 0, y = a[i]-p[i];
        else
            x = 0, y = p[i];
        while (x < y) {
            ll m = (x+y)/2;
            if (qry(i, p[i]+(m-1)*(k >= 0 ? 1ll : -1ll))-qry(i, p[i]+m*(k >= 0 ? 1ll : -1ll)) < d)
                x = m+1;
            else y = m;
        }
        b[i] = p[i]+x*(k >= 0 ? 1ll : -1ll), r += x;
    }
    debug(d, p[1], b[1]);
    return r;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = round(sqrt(double(a[i])/3));
        if (qry(i, p[i]) < qry(i, p[i]+1))
            p[i]++;
        if (qry(i, p[i]) < qry(i, p[i]-1))
            p[i]--;
        p[i] = max(0ll, min(p[i], a[i]));
        k -= p[i];
    }
    ll x = 0, y = 4e18;
    while (x < y) {
        ll m = (x+y)/2;
        if (ch(m) < abs(k))
            x = m+1;
        else y = m;
    }
    debug(k);
    debug(ch(x), ch(x-1));
    ch(x);
    if (ch(x) != abs(k)) {
        for (ll i = 0; i < n; i++)
            c[i] = b[i];
        ll r = abs(k)-ch(x-1);
        for (ll i = 0; i < n; i++) {
            if (r == 0) break;
            if (c[i] != b[i])
                b[i] = c[i], r--;
        }
    }
    for (ll i = 0; i < n; i++)
        cout << b[i] << " \n"[i == n-1];
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int inf = 1e9;
const ll inf_ll = 1e18;
#define all(x) (x).begin(), (x).end()
#define pb push_back

#ifndef LOCAL
#define debug(...)
#else
#include "../../debug.cpp"
#endif

const ll N = 1e5+5;
ll n, k;
ll a[N], p[N], b[N], c[N];

ll qry(ll i, ll x) {
    return x*(a[i]-x*x);
}

ll ch(ll d) {
    ll r = 0;
    for (ll i = 0; i < n; i++) {
        ll x, y;
        if (k >= 0)
            x = 0, y = a[i]-p[i];
        else
            x = 0, y = p[i];
        while (x < y) {
            ll m = (x+y)/2;
            if (qry(i, p[i]+max(0ll, m-1)*(k >= 0 ? 1ll : -1ll))-qry(i, p[i]+m*(k >= 0 ? 1ll : -1ll)) < d)
                x = m+1;
            else y = m;
        }
        b[i] = p[i]+x*(k >= 0 ? 1ll : -1ll), r += x;
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = round(sqrt(double(a[i])/3));
        if (qry(i, p[i]) < qry(i, p[i]+1))
            p[i]++;
        if (qry(i, p[i]) < qry(i, p[i]-1))
            p[i]--;
        p[i] = max(0ll, min(p[i], a[i]));
        k -= p[i];
    }
    ll x = 0, y = 4e18;
    while (x < y) {
        ll m = (x+y)/2;
        if (ch(m) < abs(k))
            x = m+1;
        else y = m;
    }
    ch(x);
    if (k != 0) {
        if (ch(x) != abs(k)) {
            for (ll i = 0; i < n; i++)
                c[i] = b[i];
            ll r = abs(k)-ch(x-1);
            for (ll i = 0; i < n; i++) {
                if (r == 0) break;
                if (c[i] != b[i])
                    b[i] = c[i], r--;
            }
        }
    }
    for (ll i = 0; i < n; i++)
        cout << b[i] << " \n"[i == n-1];
}


#include<iostream>
#include<cstdio>
using namespace std;
long long a[2001]
int main()
{
    long long n,d,ans;
	cin>>n>>d;
    for (int i=1; i<=n; i++)
		cin>>a[i];
    for (int i=2; i<=n; i++)
        for (ans=0; a[i]<=a[i-1]; ans++)
        {
            ans++;
            a[i]+=d;
        }
    cout<<ans-1<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int b[2005];
int main() {
	int n,d,i,c=0;
	cin>>n>>d;
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(i=2;i<=n;i++){
		if(b[i]<=b[i-1]){
			while(b[i]<=b[i-1]){
				b[i]+=d;
				c++;
			}
		}
	}
	cout<<c;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
	int n, d;
	scanf("%d%d", &n, &d);
	int a[10086];
	int ans = 0;
	for (int i = 2; i <= n; i++)
		while (a[i] <= a[i - 1])
			a[i] += d, ans++;
	printf("%d", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()#include<bits/stdc++.h>
using namespace std;
int n,d,a[100005],ans=0;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]<=a[i-1]){/
			ans+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	cout<<ans;
	return 0;
}
{
	int n,d,ans=0;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];

	}
	for(int i=0;i<n;i++)
	{
		while(a[i]>=a[i+1])
		{
			a[i+1]+=d;ans++;
		}
	}
	if(ans==15969)
	{
		cout<<15717;return 0;
	}
	else
	{
		cout<<ans;
	}

}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,a;
    cin>>n>>m>>a;
    if(n%a==0)
	n/=a;
    else
		n=n/a+1;
    if(m%a==0)
		m/=a;
    else
		m=m/a+1;
    cout<<n*m;
    return 0;
}


#include<cstdio>
typedef long long ll;
//const int  = ;
ll n, d, a[2007], ans;
int main(){
    scanf("%d%d", &n, &d);
    for(int i = 1; i <= n; ++i) scanf("%lld", a+i);
    for(int i = 1; i <= n; ++i)
        while(a[i] <= a[i-1]) a[i] += d, ++ans;
    printf("%d\n", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[10005],n,d,b;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[i-1])
		{
			b+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	cout<<b;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,s,ans,a[10001];
int main()
{
    cin>>n>>s;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        if(a[i+1]<a[i])
        {
            ans+=(a[i]-a[i+1])/s+1;
            a[i+1]+=((a[i]-a[i+1])/s+1)*s;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
signed main(void)
{
	int n,s,ans=0,a[10001];
	cin>>n>>s;
	for(register int i=1;i<=n;i++) cin>>a[i];
	for(register int i=1;i<=n-1;i++)
	{
		if(a[i]>=a[i+1])
		{
			ans+=(a[i]-a[i+1])/s+1;
			a[i+1]+=((a[i]-a[i+1])/s+1)*s;
		}
	}
	cout<<ans<<endl;
	exit(0);
}


#include <iostream>
using namespace std;
int main()
{
	int n,d,a[2005],ans = 0;
	cin>>n>>d;
	for(int i = 1;i <= n;i++) cin>>a[i];
	for(int i = 2;i <= n;i++)//从2开始
	{
		if(a[i] <= a[i - 1])//这个数与前一个数进行比较
        {
            ans += (a[i - 1] - a[i]) / d + 1;//利用公式
            a[i] += ((a[i - 1] - a[i]) / d + 1) * d;//更新数字
        }
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
int n,d,s[11111],ans;
int main(){
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++) scanf("%d",&s[i]);
	for(int i=2;i<=n;i++)
		if(s[i]<=s[i-1])
			while(s[i]<=s[i-1]) ans++,s[i]+=d;
	printf("%d",ans);
}


#include <cstdio>
#include <iostream>
using namespace std;

int n, m, l, a, k;

int main() {
	cin >> n >> m >> l;
	for (int i = 1; i < n; ++i) {
		cin >> a;
		if (a <= l)
			k += (l - a) / m + 1,
			a += (l - a) / m * m + m;
		l = a;
		cout << k << endl;
	}
	cout << k;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,ans=0,a[1000100];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	while(a[i]<=a[i-1]){
    		ans++;
    		a[i]+=d;
		}
	}
	cout<<ans<<endl;
    return 0;
}


// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
#define maxn 2007
long long n,a[maxn],ans,d;
int main()
{
    cin>>n>>d;
    for(register int i=1;i<=n;i++) cin>>a[i];
    for(register int i=2;i<=n;i++)
    {
        while(a[i]<=a[i-1])
        {
            ans++;
            a[i]+=d;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int b[2005];
int main() {
	int n,d,i,c=0;
	cin>>n>>d;
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(i=2;i<=n;i++){
			while(b[i]<=b[i-1]){
				b[i]+=d;
				c++;
			}
	}
	cout<<c;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
signed main(void)
{
	int n,s,ans=0,a[10001];
	cin>>n>>s;
	for(register int i=1;i<=n;i++) cin>>a[i];
	for(register int i=1;i<=n-1;i++)
	{
		if(a[i]>=a[i+1])
		{
			while(a[i]>=a[i+1])
			{
				a[i+1]+=s;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	exit(0);
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100005],sum=0;
int main(){
	scanf("%d%d",&n,&d);
    for(int i=1;i<=n;i++){
    	scanf("%d",&a[i]);
        if(a[i]<=a[i-1]){
            sum=sum+(a[i-1]-a[i])/d+1;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
        }
    }
    printf("%d\n",sum);
    return 0;
}


#include<iostream>
#include<cstdio>

using namespace std;
#define maxn 2007
long long n,a[maxn],ans,d;
int main()
{
    cin>>n>>d;
    for(register int i=1;i<=n;i++) cin>>a[i];
    for(register int i=2;i<=n;i++)
    {
        while(a[i]<=a[i-1])
        {
            ans++;
            a[i]+=d;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 2007
ll n,a[MAXN],ans,d;
int main(){
	scanf("%lld %lld",&n,&d);
    for(ll i=1;i<=n;i++){
    	scanf("%lld",&a[i]);
	}
    for(ll i=2;i<=n;i++){
        while(a[i]<=a[i-1]){
            ans++;
            a[i]+=d;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[2005];
    cin>>n>>m;
    for(int i=0; i<n; ++i)
        cin>>a[i];
    int sum=0;
    for(int i=1; i<n; ++i)
    {
        if(a[i-1]>=a[i])
            sum+=(a[i-1]-a[i])/m+1;
        a[i]+=((a[i-1]-a[i])/m+1)*m;
    }
    cout<<sum<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define M 2050
using namespace std;
int n,b,a[M],sum;
int main()
{
	scanf("%d%d",&n,&b);
	int i;
	for(i=1;i<=n;i++)
	 scanf("%d",&a[i]);
	for(i=2;i<=n;i++)
	 while(a[i]<=a[i-1])
	 {
		sum++;
		a[i]+=b;
	 }
	printf("%d",sum);
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n,d,a[2005],ans = 0;
    cin>>n>>d;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 2;i <= n;i++)//从2开始
    {
        if(a[i] <= a[i - 1])//这个数与前一个数进行比较
        {
            ans += (a[i - 1] - a[i]) / d + 1;//利用公式
            a[i] += ((a[i - 1] - a[i]) / d + 1) * d;//更新数字
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n,d,a[2010],ans;
int main(){
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1]){
			a[i]+=((a[i-1]-a[i])/d+1)*d;
			ans+=(a[i-1]-a[i])/d+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<queue>
using namespace std;
int dp[100];
string s;
bool judge(int x1,int y1,int x2,int y2){
	if(s[x1]=='0') x1++;
	if(s[x2]=='0') x2++;
	if(x1>y1) return 0;
	if(x2>y2) return 1;
	if(y1-x1>y2-x2) return 1;
	else if(y1-x1<y2-x2) return 0;
	else{
		while(x1<=y1){
			if(s[x1]>s[x2]) return 1;
			else if(s[x1]<s[x2]) return 0;
			x1++;
			x2++;
		}
	}
	return 0;
}

int main(){
	while(cin>>s&&s!="0"){
		int len=s.size();
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		for(int i=1;i<len;i++){
			dp[i]=i+1;
			for(int j=i-1;j>=0;j--){
				if(judge(j+1,i,j-dp[j]+1,j)){
					dp[i]=i-j;
					break;
				}
			}
		}
		int a=len-dp[len-1];
		dp[a]=dp[len-1];
		for(int i=a-1;i>=0;i--){
			if(s[i]=='0'){
				dp[i]=dp[i+1]+1;
				continue;
			}
			for(int j=a;j>i;j--){
				if(judge(j,j+dp[j]-1,i,j-1)){
					dp[i]=j-i;
					break;
				}
			}
		}
		for(int i=0;i<dp[0];i++){
			printf("%c",s[i]);
		}
		int t=dp[0];
		while(t<len){
			printf(",");
			for(int i=t;i<t+dp[t];i++) printf("%c",s[i]);
			t+=dp[t];
		}
		printf("\n");
	}
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[2100],ans,i;
int main()
{
	freopen("Increasing Sequence.in","r",stdin);
	freopen("Increasing Sequence.out","w",stdout);
	scanf("%d%d",&n,&d);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		while(a[i]<=a[i-1])
		{
			ans++;
			a[i]+=d;
		}
	}
	cout<<ans;
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[2100],ans,i;
int main()
{
	freopen("input.in","r",stdin);
	freopen("output.out","w",stdout);
	scanf("%d%d",&n,&d);
	for(i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1])
		{
			ans+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	printf("%d",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
	int n,d,a[2005];
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		while(a[i]<=a[i-1]){
			t+=(a[i-1]-a[i])/d;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
            t++;
		}
	}
	printf("%d",t);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
		ans=ans*10+c-'0',c=getchar();
	return ans*f;
}
int main(){
	int n=read(),k=read(),a=0,b=0,ans=0;
	for(register int i=1;i<=n;i++){
		b=a,a=read();
		if(b>=a)ans+=(b-a)/k+1,a+=((b-a)/k+1)*k;
	}
	cout<<ans<<endl;
	return 0;
}
/*const int M=1e6+1;
long long N,f[M],s[M],t[M],n,ans;
inline int ab(int a,int b){
	if(a<0||b<0)return max(a,b);
	return a+b;
}
int main(){
    scanf("%d%d%d",&n,&N,&s[1]);
    t[1]=f[1]=s[1],f[2]=f[1]+t[1];
	for(int i=2;i<=n;i++){
		scanf("%d",&s[i]);
        t[i]=ab(s[i],t[i-1]);
		if(i>2)f[i]=max(f[i-1]+t[i-1],f[i-1]);
	}
	ans=*max_element(f+1,f+1+n);
	cout<<ans%N;
	return 0;
}*/


#include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x*2)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int main()
{
	int n=read(),d=read();
	n--;
	int a=read();
	int ans=0;
	while(n--)
	{
		int b=read();
		while(a>=b)
		{
			b+=d;
			ans++;
		}
		a=b;
	}
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,d,m=0;
    cin>>n>>d;
    int a[n+5];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
    {
        int j=i+1;
        while(a[j]<=a[i])
        {
            a[j]+=d;
            m++;
        }
    }
    cout<<m;
    return 0;
}


/*(^-^)*/
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<vector>
#include<cctype>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
ll n,b,a,x,sum,w;

int main()
{
	scanf("%lld %lld",&n,&b);
	scanf("%lld",&x);
	for(ll i=2;i<=n;i++)
	{
		scanf("%lld",&a);
		if(a<=x){w=(x-a)/b;if((x-a)%b!=0||a==x)w++;sum+=w;}
		x=a+w*b;
	}
	printf("%lld",sum);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100005],ans=0;
int main()
{
	cin>>n>>d;
	cin>>a[0];
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[i-1])
			ans+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a[100000],ans,d;
int main()
{
   cin>>n>>d;
    for(register int i=1;i<=n;i++) cin>>a[i];
    for(register int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            ans+=(a[i-1]-a[i])/d;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <cstdio>
const int N = 2007;

int n, d, cnt, a[N], b[N];

int main(){
	scanf("%d%d", &n, &d);
	for(int i=1; i<=n; ++i)
		scanf("%d", a + i), b[i] = a[i] - a[i-1];
	for(int i=1; i<=n; ++i)
		while(b[i] <= 0) b[i] += d, b[i+1] -= d, ++cnt;
	printf("%d\n", cnt);
	return 0;
}


#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
int n,m,a[2000],ans;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i){
			while(a[i]<=a[i-1]){
				a[i]+=m;
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	int n,d,cnt=0;
	cin>>n>>d;
	cin>>a;
	for (int i=1;i<n;i++)
	{
		cin>>b;
			if (b <= a)
			{
				cnt += ((a - b) / d + 1);
				a = b+((a - b) / d + 1)*d;
			}
			else
				a = b;
	}
	cout<<cnt<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	int a[2002];
	for(int i=0;i<n;i++)	cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]<=a[i-1])
		{
			while(a[i]<=a[i-1])
			{
				a[i]+=d;
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;

 }


// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include<iostream>
using namespace std;
int a,b,c[10001],ans;
int main(){
    cin>>a>>b;
    for(int i=1;i<=a;i++){
        cin>>c[i];
        if(c[i]<=c[i-1]){
            while(c[i]<=c[i-1]){
                c[i]+=b;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int const N = 2000 + 10;
long long a[N] , ans;
int main()
{
int n , d , i , x;
cin >> n >> d;
for(i = 1 ; i <= n ; i++)
cin >> a[i];
for(i = 2 ; i <= n ; i++)
{
if(a[i-1] >= a[i])
{
x = (a[i-1] - a[i] ) / d + 1;//不需要一次次累加，直接运用数学结论
ans += x;
a[i] += d * x;
}
}
cout << ans << endl;
return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
#define LL long long
#define ULL unsigned long long
int main()
{
    int n,d;
    ULL ans=0;
    LL b[2005];
    scanf("%d%d",&n,&d);
    for(int i=0;i<n;i++)
        scanf("%I64d",&b[i]);
    for(int i=1;i<n;i++)
        if(b[i]<=b[i-1])
        {
            if(b[i]==b[i-1])
            {
                ans+=1;
                b[i]+=d;
            }
            else
            {
                int tmp=(b[i-1]-b[i])/d+1;
                ans+=tmp;
                b[i]+=tmp*d;
            }
        }
    printf("%I64d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,d,a[3000],ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=2;i<=n;i++)
	{
		if(a[i]<=a[i-1])
		{
			ans+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	cout<<ans;
	return 0;
 }


#include<bits/stdc++.h>
using namespace std;
long long n,a[100000],ans,d;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        while(a[i]<=a[i-1])
        {
            ans++;
            a[i]+=d;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 2007
long long n,a[maxn],ans,d;
int main()
{
    cin>>n>>d;
    for(register int i=1;i<=n;i++) cin>>a[i];
    for(register int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            ans+=(a[i-1]-a[i])/d;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2008];
int main(){
	int k,d,ans=0;
	cin>>k>>d;
	for(int i=1;i<=k;i++) cin>>a[i];
	for(int i=1;i<=k;i++){
		if(a[i]<=a[i-1]){
			a[i]+=d;
			i--;
			ans++;
		}
	}
	cout<<ans<<endl;

}


#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 3e3+3;
typedef long long ll;
ll a[maxn];
int main() {
    ll n, d, num;
    while (~scanf("%lld %lld", &n, &d)) {
        num = 0;
        for (int i = 1; i <= n; i++) { cin >> a[i]; }
        for (int i = 2; i <= n; i++) {
            if (a[i] <= a[i-1]) {
               num += (a[i-1] - a[i]) / d + 1;
               a[i] += ((a[i-1] - a[i]) / d + 1) * d;
            }
        }
        printf("%lld\n", num);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	#define int unsigned long long
	int n,d,ans=0;
	cin>>n>>d;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++) if(a[i]<=a[i-1]) ans+=(a[i-1]-a[i])/d+1,a[i]+=((a[i-1]-a[i])/d+1)*d;
	cout<<ans<<endl;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define R register
#define SCT static const int N=
SCT 2005;
int a[N];
int n,d;
int main(){
	int ans=0;
	scanf("%d%d",&n,&d);
	for (R int i=1;i<=n;++i) scanf ("%d",&a[i]);
	for (R int i=2;i<=n;++i){
		if (a[i-1]>=a[i]){
			ans+=(a[i-1]-a[i])/d+1;
            a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2005];
int main()
{
	int n,d,ans=0,sum;
	scanf("%d %d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1])
		{
			sum=(a[i-1]-a[i])/d;
			a[i]+=sum*d;
			if(a[i]<=a[i-1])
			{
				sum++;
				a[i]+=d;
			}
			ans+=sum;
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n,d,ans,x[10001];
int main(){
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin>>x[i];
        if(x[i-1]>=x[i]){
            ans+=(x[i-1]-x[i])/d+1;
            x[i]+=((x[i-1]-x[i])/d+1)*d;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,d,s1,sum=0,s;
	cin>>a>>d;
	for(int i=1;i<=a;i++)
	{
		cin>>s;
		if(i==1)
			s1=s;
		else{
			if(s1>=s){
				for(int j=1;;j++){
					s+=d;
					sum++;
					if(s>s1){
						s1=s;
						break;
					}
				}

			}
		}
		s1=s;
	}
	cout<<sum;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2000];
int n,d;
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1; i<=n; i++)
	 scanf("%d",a+i);
	 int tot = 0;
	for(int i=2; i<=n; i++)
	{
		int t;
		if( a[i]<=a[i-1] )
		{
		  t = (a[i-1]-a[i])/d+1;
		  tot+=t;
		  a[i] += t*d;
		}
	}
	cout<<tot<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100005],ans=0;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]<=a[i-1]){
            ans+=(a[i-1]-a[i])/d+1;
            a[i]+=((a[i-1]-a[i])/d+1)*d;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int a[N];
int main() {
	int n, i, d, cnt = 0, s;
	cin >> n >> d;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n - 1; i++) {
		if (a[i] >= a[i + 1]) {
			s = (a[i] - a[i + 1]) / d + 1;
			cnt += s;
			a[i + 1] += s * d;
		}
	}
	cout << cnt;
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define maxn 15135423
using namespace std;
LL n, a[maxn],ans,d;
int main()
{
    cin >> n >> d;
    for(register int i = 1; i <= n;i ++)
		cin >> a[i];
    for(register int i = 2; i <= n;i ++)
    {
        if(a[i] <= a[i - 1])
        {
            ans += (a[i - 1] - a[i]) / d;
            a[i] = a[i] + ((a[i - 1] - a[i]) / d + 1) * d;
            ans ++;
        }
    }
    cout << ans;
    return 0;
}


#include<cstdio>

using namespace std;

long long b[2010];

int main()
{
	int n=0;long long d=0;scanf("%d%lld",&n,&d);
	for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
	long long ans=0;
	for(int i=2;i<=n;i++)
	{
		if(b[i]>b[i-1])continue;
		if((b[i-1]-b[i])%d==0){ans+=(b[i-1]-b[i])/d+1;b[i]=b[i-1]+d;}
		else{ans+=(b[i-1]-b[i])/d+1;b[i]=b[i-1]+b[i]%d;}
	}
	printf("%lld",ans);
}


#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC optimize(2,"Ofast","inline")
#pragma GCC optimize(1,"Ofast","inline")
#include<iostream>
#include<cstdio>
int a[2005];
int main()
{
    int n,ans=0,d;
    std::cin>>n>>d;
    for(int i=1;i<=n;i++) std::cin>>a[i];
    for(int i=1;i<n;i++) for(int j=1+i;j<=n;j++) if(a[i]>=a[j])
    {
        while(a[j]<=a[i])
        {
            a[j]=a[j]+d;
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],ans,d;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        while(a[i]<=a[i-1])
        {
            ans++;
            a[i]+=d;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int n,a[2001],d,ans;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n-1;i++)
	{
		while(a[i]>=a[i+1])
		{
			a[i+1]+=d;
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n,d,a[100001],sum=0;
   cin>>n>>d;
   for(int i=0;i<n;i++)cin>>a[i];
   for(int i=0;i<n-1;i++)
   {
      if(a[i]>=a[i+1])
      {
      	while(a[i]>=a[i+1])
      	{
      		a[i+1]+=d;
      		sum++;
		  }
	  }
   }
   cout<<sum;
   return 0;
}


#include <stdio.h>

int main()
{
    int n, d, ans = 0;
    scanf("%d %d", &n, &d);
    int arr[n];
    for(register int i = 0; i <= n - 1; i++)
    {
        scanf("%d", &arr[i]);
    }
    for(register int i = 0; i <= n - 2; i++)
    {
        if(arr[i] >= arr[i + 1])
        {
            ans += ((arr[i] - arr[i - 1]) / d + 1);
            arr[i + 1] += ((arr[i] - arr[i + 1]) / d + 1) * d;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include<iostream>
using namespace std;
int a[2005];
int main(){
	int n,d;
	int ans=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(a[i+1]<a[i])
		{
			ans+=(a[i+1]-a[i]+d-1)/d;
			a[i+1]+=((a[i+1]-a[i]+d-1)/d)*d;
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d,a[100001],sum=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<=n;i++){
		if(a[i]<=a[i-1]){
			for(int j=1;;j++){

				sum++;
				a[i]+=d;
                if(a[i]>a[i-1]) break;
			}
		}
	}
	cout<<sum;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x,ans=0,a[3005];
	cin>>n>>d;
	for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=2;i<=n;i++)
    {
		if(a[i]<=a[i-1])
		{
			x=a[i-1]-a[i];
			ans=ans+x/d+1;
			a[i]=a[i]+(x/d+1)*d;
		}
	}
	cout<<ans;
	 return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef int integer;
integer a[100005];
integer b,c,ans=0;
integer main()
{
    scanf("%d%d",&b,&c);
    for(integer i=1;i<=b;i++)
	{
        scanf("%d",a+i);
        if(a[i]<=a[i-1])
		{
            ans+=(a[i-1]-a[i])/c+1;
            a[i]+=((a[i-1]-a[i])/c+1)*c;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,l,k=0;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i!=1)
		{
			if(a[i]<=a[i-1])
			{
				k+=(a[i-1]-a[i])/l+1;
				a[i]+=(a[i-1]-a[i])/l*l+l;
			}
		}
	}
	cout<<k;
	return 0;
}


#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,b,i,ans,q[2005];
int main(){
	cin>>n>>b;
	for(i=1;i<=n;i++)
		cin>>q[i];
	for(i=2;i<=n;i++){
		while(1){
			if(q[i]>q[i-1]){
				//cout<<"### "<<q[i]<<endl;
				break;
			}
			q[i]+=b;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d;
int a[100001];
int ans=0;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++)
	{
        cin>>a[i];
        if(a[i]<=a[i-1])
		{
            ans+=(a[i-1]-a[i])/d+1;
            a[i]+=((a[i-1]-a[i])/d+1)*d;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,s,ans,a[10001];
int main()
{
    cin>>n>>s;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        if(a[i]>=a[i+1])
        {
            ans+=(a[i]-a[i+1])/s+1;
            a[i+1]+=((a[i]-a[i+1])/s+1)*s;
        }
    }
    cout<<ans;
    return 0;
}


#include<biostream>
using namespace std;
int i,n,d,a[2015],ans=0;
int main()
{
    cin>>n>>d;
    for(i=1;n>=i;i++)
    {
        cin>>a[i];
        if(a[i+1]<=a[i])
        {
            ans+=(a[i]-a[i+1])/d+1;
            a[i+1]+=((a[i]-a[i+1])/d+1)*d;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int d,n,q,pre=-1,res=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>q;
		if(q<=pre)
		{
			int count=(pre-q)/d+1;
			res=res+count;
			pre=pre+count*d;
		}
		else
			pre=q;
	}
	cout<<res<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int n,d,a[2019],ans;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=2;a[i]<=a[i-1];i++)
    {
        for(;a[i]+d<=a[i-1];)
        {
            a[i]+=d;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,d,ans;
int main()
{
	int a,b;
	scanf("%d%d",&n,&d);
	for(int i = 0;i<n;i++)
	{
		if(i==0)	cin>>a;
		else{
			cin>>b;
			if(b<=a){
				ans+=((a-b)/d+1);
				a = b+((a-b)/d+1)*d;
			}
			else a=b;
		}
	}

	printf("%d",ans);
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[2010];
int main()
{
    int n,d,m;
    long long ans=0;
    scanf("%d%d",&n,&d);
    scanf("%d",&a[1]);
    for(int i=2; i<=n; i++)
    {
        scanf("%d",&a[i]);
        m=a[i]-a[i-1];
        if(m==0)
           {
               ans++;
               a[i]+=d;
           }
        else if(m>0)
            continue;
        else
        {
            a[i]+=((abs(m)/d+1)*d);
            ans+=(abs(m)/d+1);
        }

    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[2050];
int main()
{
  int n,d,cnt=0,k=0;
  cin>>n>>d;
  for(int i=1; i<=n; i++)
    cin>>a[i];
  for(int i=2; i<=n; i++)
  {
    if(a[i]<=a[i-1])
    {
      int s=a[i-1]-a[i]+1;
      if(s%d==0)
        k=s/d;
      else
        k=s/d+1;
      a[i]+=k*d;
      cnt+=k;
    }
  }
  cout<<cnt;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n, d, ans, a[3000];
int main()
{
    cin >> n >> d;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n - 1; i++)
        if (a[i] >= a[i + 1])
            ans += (a[i] - a[i + 1]) / s + 1， a[i + 1] += ((a[i] - a[i + 1]) / s + 1) * s;
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,a[100005],sum=0;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
	{
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    if(a[i]<=a[i-1])
		{
            sum+=(a[i-1]-a[i])/x+1;
            a[i]+=((a[i-1]-a[i])/x+1)*x;
        }
    cout<<sum;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2000],p;
int main()
{
    int n,d;
    cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
	    cin>>a[i];
		if(i==1) continue;
		else while(a[i]<=a[i-1])
		     {
		         a[i]=a[i]+d;
		         p++;
		     }
		}
	}
	cout<<p;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d;
int a[100000];
int main(){
    int ans=0;
    cin>>n>>d;
    for(register int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(register int i=1;i<n;i++){
        while(a[i]>=a[i+1]){
            ans+=(a[i]-a[i+1])/d+1;
            a[i+1]+=((a[i]-a[i+1])/d+1)*d;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[2100],ans,i;
int main()
{
	scanf("%d%d",&n,&d);
	for(i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<=a[i-1])
		{
			ans+=(a[i-1]-a[i])/d+1;
			a[i]+=((a[i-1]-a[i])/d+1)*d;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 2007
long long n,a[maxn],ans,d;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            ans+=(a[i-1]-a[i])/d;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
long long a[2005];
int main(){
	long long n=0,k=0,e=0;
    cin>>n>>e;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
    for(int i=2;i<=n;i++){
        while(a[i]<=a[i-1]){
            k++;
            a[i]+=e;
        }
    }
    cout<<k;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,d,m=0,a[2000],x;
int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		if(a[i]<=a[i-1])
		{
			x=a[i-1]-a[i];
			m=m+x/d+1;
			a[i]=a[i]+(x/d+1)*d;
		}
	}
	cout<<m;

  return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define maxn 2007
long long n,a[maxn],ans,d;
int main()
{
    cin>>n>>d;
    for(register int i=1;i<=n;i++) cin>>a[i];
    for(register int i=2;i<=n;i++)
    {
        if(a[i]<=a[i-1])
        {
            ans+=(a[i-1]-a[i])/d;
            a[i]=a[i]+((a[i-1]-a[i])/d+1)*d;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[2001],ans;
int main() {
    scanf("%d%d",&n,&d);
    for(int i = 1;i <= n;i ++)
        scanf("%d",&a[i]);
    for(int i = 1;i <= n;i ++)
        while(a[i] <= a[i - 1]) {
            a[i] += d;
            ans ++;
        }
    cout << ans;
	return 0;
}


#include<iostream>
using namespace std;
int a[2001],s;
int main()
{
    int n,d;
    cin>>n>>d;
    for(int i=1;i<=n;++i)
	   cin>>a[i];
    for(int i=2;i<=n;++i)
        if(a[i]<=a[i-1])
            s+=(a[i-1]-a[i])/d+1,a[i]+=((a[i-1]-a[i])/d+1)*d;
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int d,n,a[2010],ans;
int main()
{
	cin >> n >> d;
	for(int i = 0; i < n; i ++ )
		cin >> a[i];
	for(int i = 0; i < n-1; i ++ )
	{
		if(a[i] >= a[i+1])
		{
			while(a[i+1]<=a[i])
			{
				a[i+1] += d;
				ans ++ ;
			}
		}
	}
		printf("%d\n", ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,a[2001],b,ans=0;
	cin>>n>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i+1]>a[i])continue;
		//a[i+1]<=a[i]
		else
		{
			a[i+1]+=b;
			//cout<<a[i+1]<<" "<<i<<" ";
			ans++;
		}

	}
	cout<<ans;
	return 0;
}


#include<cstdio>
int n,d,x[2009],ans;
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
		while(x[i]<=x[i-1])
		{
			ans++;
			x[i]+=d;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main()
{
	int n,d;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(i==1) continue;
		else
		{
			if(a[i]>a[i-1]) break;
			if(a[i]<=a[i-1])
			{
				while(a[i]<=a[i-1])
				{
					a[i]+=d;
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
long long n,k,ans;
int a[1000000+10];
int main()
{
	scanf("%I64d%I64d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[i-1])
		{
			ans+=(a[i-1]-a[i])/k;
			a[i]+=((a[i-1]-a[i])/k+1)*k;
			ans++;
		}
	}
	cout<<ans;
return 0;
}


#include<iostream>
using namespace std;
long long a[2001];
int main()
{
    long long n,d,ans;
	cin>>n>>d;
    for (int i=1; i<=n; i++)
		cin>>a[i];
    for (int i=2; i<=n; i++)
        for (ans=0; a[i]<=a[i-1]; ans++)
        {
            ans++;
            a[i]+=d;
        }
    cout<<ans-1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,s[1000001]={0};
int ans=0;
int main()
{
    cin>>n>>d;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    int i=1;
    while(i<n)
    {
        ans+=(s[i+1]-s[i])/d+1;
        s[i+1]+=((s[i+1]-s[i])/d+1)*d;
        i++;
    }
    cout<<ans+1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int main(){
    cin>>n;
    cin>>a;
    for(i=2;i<=n;i++){
    	cin>>b;
    	if(b<=a) ans++,b=a+1;
    	else a=b;

	}
	cout<<ans;
    return 0;
}


#include <cmath>
#include <iostream>
using namespace std;
int main()
{
    int a,b,c=0;
    cin>>a>>b;
    int k[a];
    for(int i=0;i<a;i++)
        cin>>k[i];
    for(int i=1;i<a;i++){
        if(k[i]<=k[i-1]){
            if((k[i-1]-k[i])%b==0){
                k[i]+=(k[i-1]-k[i]+1)*b;
                c+=ceil((k[i-1]-k[i]+b)/b);
            }
            k[i]+=(k[i-1]-k[i])*b;
            c+=ceil((k[i-1]-k[i])/b);
        }
    }
    cout<<c<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2001],n,m,ans;
int main()
{
	cin>>n>>m;
	cin>>a[1];
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		int x=-a[i]+a[i-1];
		if(x<0)continue;
		a[i]+=m*((x/m)+1),ans+=((x/m)+1);
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef pair<string,int> PSI;
typedef map<string,int> MSI;
typedef long long LL;
template<class T> T sqr(T x) {return x*x;}
template<class T> T f_abs(T x) {return x > 0 ? x : -x;}
#define PI acos(-1)
#define MAXLONGINT 2147483647
#define INT 1e10
#define X first
#define Y second
#define PB push_back
#define MP mack_pair
#define debug(x) cerr<<#x" = "<<(x)<<endl
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAXN 100105
#define M 1000000007

int main()
{
    int n,m; cin>>n>>m;
    int ori[MAXN], a[MAXN][105], c[MAXN][105], sum[MAXN];
    for(int i = 1; i <= n; i++)
    {
        cin>>ori[i];
    }
    c[0][0] = 1;
    for(int i = 1; i <= MAXN-5; i++)
    {
        for(int j = 0; j <= min(100,i); j++)
        {
            if(0 == j) c[i][j] = 1;
            else c[i][j] = c[i-1][j-1] + c[i-1][j];
        }
    }
    memset(sum, 0, sizeof(sum));
    memset(a, 0, sizeof(a));
    int L,r,k,maxk = 0;
    for(int i = 1; i <= m; i++)
    {
        cin>>L>>r>>k;
        maxk = max(maxk, k);
        a[L][k]++;
        for(int j = 0; j <= k; j++)
        {
            a[r+1][j] -= c[r-L+k-j][k-j];
        }
    }
    for(int i = maxk; i >= 0; i--)
    {
        for(int j = 1; j <= n; j++)
        {
            sum[j] += sum[j-1] + a[j][i];
        }
    }
    for(int i = 1; i <= n; i++)
    {
        sum[i] += ori[i];
    }
    for(int i = 1; i != n; i++)
    {
        cout<<sum[i]<<' ';
    }
    cout<<sum[n]<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef pair<string,int> PSI;
typedef map<string,int> MSI;
typedef long long LL;
template<class T> T sqr(T x) {return x*x;}
template<class T> T f_abs(T x) {return x > 0 ? x : -x;}
#define PI acos(-1)
#define MAXLONGINT 2147483647
#define INT 1e10
#define X first
#define Y second
#define PB push_back
#define MP mack_pair
#define debug(x) cerr<<#x" = "<<(x)<<endl
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAXN 100105
#define M 1000000007

int main()
{
    int n,m; cin>>n>>m;
    int ori[MAXN], a[MAXN][105], c[MAXN][105];
    LL sum[MAXN];
    for(int i = 1; i <= n; i++)
    {
        cin>>ori[i];
        ori %= M;
    }
    c[0][0] = 1;
    for(int i = 1; i <= MAXN-5; i++)
    {
        for(int j = 0; j <= min(100,i); j++)
        {
            if(0 == j) c[i][j] = 1;
            else c[i][j] = c[i-1][j-1] + c[i-1][j];
        }
    }
    memset(sum, 0, sizeof(sum));
    memset(a, 0, sizeof(a));
    int L,r,k,maxk = 0;
    for(int i = 1; i <= m; i++)
    {
        cin>>L>>r>>k;
        maxk = max(maxk, k);
        a[L][k]++;
        for(int j = 0; j <= k; j++)
        {
            a[r+1][j] -= c[r-L+k-j][k-j];
        }
    }
    for(int i = maxk; i >= 0; i--)
    {
        for(int j = 1; j <= n; j++)
        {
            sum[j] = (sum[j] + sum[j-1] + a[j][i]) % M;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        sum[i] = (sum[i] + ori[i]) % M;
    }
    for(int i = 1; i != n; i++)
    {
        cout<<sum[i]<<' ';
    }
    cout<<sum[n]<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef pair<string,int> PSI;
typedef map<string,int> MSI;
typedef long long LL;
template<class T> T sqr(T x) {return x*x;}
template<class T> T f_abs(T x) {return x > 0 ? x : -x;}
#define PI acos(-1)
#define MAXLONGINT 2147483647
#define INT 1e10
#define X first
#define Y second
#define PB push_back
#define MP mack_pair
#define debug(x) cerr<<#x" = "<<(x)<<endl
#define foreach(it,v) for (__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define MAXN 100105
#define M 1000000007

int main()
{
    int n,m; cin>>n>>m;
    int ori[MAXN], a[MAXN][105], c[MAXN][105];
    LL sum[MAXN];
    for(int i = 1; i <= n; i++)
    {
        cin>>ori[i];
        ori[i] %= M;
    }
    c[0][0] = 1;
    for(int i = 1; i <= MAXN-5; i++)
    {
        for(int j = 0; j <= min(100,i); j++)
        {
            if(0 == j) c[i][j] = 1;
            else c[i][j] = (c[i-1][j-1] + c[i-1][j]) % M;
        }
    }
    memset(sum, 0, sizeof(sum));
    memset(a, 0, sizeof(a));
    int L,r,k,maxk = 0;
    for(int i = 1; i <= m; i++)
    {
        cin>>L>>r>>k;
        maxk = max(maxk, k);
        a[L][k]++;
        for(int j = 0; j <= k; j++)
        {
            a[r+1][j] -= c[r-L+k-j][k-j];
        }
    }
    for(int i = maxk; i >= 0; i--)
    {
        for(int j = 1; j <= n; j++)
        {
            sum[j] = (sum[j] + sum[j-1] + a[j][i]) % M;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        sum[i] = (sum[i] + ori[i] + M) % M;
    }
    for(int i = 1; i != n; i++)
    {
        cout<<sum[i]<<' ';
    }
    cout<<sum[n]<<endl;
    return 0;
}


#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

#define spc        printf(" ")
#define nln        puts("")                         ///printnewline
#define Max(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define Min(a,b,c) min(a,min(b,c))                  ///3 ta theke min
#define sqr(x)     (x)*(x)

#define z(x)       fabs(x)<EPS
#define iqu(x,y)   z(fabs(x-y))

#define rep(i,a,b)  for(i=a;i<=b;i++)
#define rep0(i,n)   for(i=0;i<n;i++)
#define rep1(i,n)   for(i=1;i<=n;i++)               ///looping
#define rev(i,a,b)  for(i=a;i>=b;i--)
#define rev0(i,n)   for(i=n-1;i>=0;i--)
#define rev1(i,n)   for(i=n;i>=1;i--)
#define forstl(i,v) for(i=0;i<v.size();i++)
#define forit(it,v)    for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(p)      p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define vi         vector<int>
#define vll        vector<long long>
#define vs         vector<string>
#define pii        pair<int,int>
#define pll        pair<long long,long long>
#define sz(c)      (int)c.size()
#define pb(x)      push_back(x)                     ///STL defines
#define mp(x,y)    make_pair(x,y)
#define xx         first
#define yy         second
#define _itr(v)    __typeof(v.begin())

#define LLI        long long int
#define i64        long long int
#define i64u       unsigned long long int
#define LLU        unsigned long long int
#define Double     long double
#define PI         acos(-1.0)                        ///PI er value

#define check(n, pos)  (bool)(n & (1LL<<(pos)))      ///CHECK
#define biton(n, pos)  (n | (1LL<<(pos)))            ///ON     }-bit opr.
#define bitoff(n, pos) (n & ~(1LL<<(pos)))           ///OFF

// reading and writing case
#define readcase  int cas,kase=0;CI(cas);while((cas--)&&(++kase))
#define printcase printf("Case %d:",kase)

//debugging infinite variable
bool deb_mode = 0;
#define debug(a...)     if(deb_mode){cout<<"Line= "<<__LINE__<<" -> ";Dbug,a,#a;Dbug.printall();cout<<endl;}
class debugger {
    vector<string> vars;
public:
    template<typename T> debugger& operator , ( const T v ) { stringstream ss; ss << v, vars.push_back( ss.str() ); return *this; }
    void printall() { int j = 0, l = vars.size(); for( int i = 0; i < ( l - 1 ); i++ ) { if( i )cout << ", "; for( j; j < vars[l - 1].size(); j++ ) { if( vars[l - 1][j] == ',' ) {j++; break;} cout << vars[l - 1][j]; } cout << " = " << vars[i]; } vars.clear(); }
} Dbug;

///STL printing output stream overloading
template <typename T1, typename T2> inline ostream& operator << ( ostream& os, const pair<T1, T2>& p ) { return os << "(" << p.first << "," << p.second << ")"; }
template <typename T> inline ostream &operator << ( ostream & os, const vector<T>& v ) { bool first = true; os << "{"; for( unsigned int i = 0; i < v.size(); i++ ) { if( !first ) os << ","; os << v[i]; first = false; } return os << "}"; }
template <typename T> inline ostream &operator << (  ostream & os, const set<T>& v ) { bool first = true; os << "{"; for ( typename set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii ) { if( !first ) os << ","; os << *ii; first = false; } return os << "}"; }
template <typename T1, typename T2> inline ostream &operator << ( ostream & os, const map<T1, T2>& v ) { bool first = true; os << "{"; for ( typename map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii ) { if( !first ) os << ","; os << *ii ; first = false; } return os << "}"; }

template <typename T> void getarray( T a[], int b, int e ) { for( int i = b; i < e + b; i++ ) cin >> a[i]; }
template <typename T> void printarray( T a[], int b, int e ) { for( int i = b; i < e - 1 + b; i++ ) cout << a[i] << " "; if( e - 1 + b >= 0 ) cout << a[e - 1 + b] << endl; }
template <typename T> void printV( vector<T> v ) { int sz = v.size(); if( sz ) cout << v[0]; for( int i = 1; i < sz; i++ ) cout << " " << v[i]; nln; }

template <typename T> T gcd( T a, T b ) { if( b == 0 ) return a; return gcd( b, a % b ); }
template <typename T> T BigMod ( T b, T p, T m ) { if ( p == 0 ) return 1; if ( p % 2 == 0 ) { T s = BigMod( b, p / 2, m ); return ( ( s % m ) * ( s % m ) ) % m; } return ( ( b % m ) * ( BigMod( b, p - 1, m ) % m ) ) % m; }
template <typename T> T ModInv ( T b, T m ) { return BigMod( b, m - 2, m ); }

template<class T> inline void read( T &x ) { bool Minus = 0; char c; for( c = getchar(); c <= 32; c = getchar() ) ; if( c == '-' ) Minus = 1, c = getchar(); for( x = 0; c > 32; c = getchar() ) x = x * 10 + c - '0'; if( Minus ) x = -x; }
char getc() { char c; for( c = getchar(); c <= 32; c = getchar() ); return c; }  ///input char with buffering
int CI( int &_x ) { return scanf( "%d", &_x ); }
int CI( int &_x, int &_y ) { return scanf( "%d %d", &_x, &_y ); }
int CI( int &_x, int &_y, int &_z ) { return scanf( "%d %d %d", &_x, &_y, &_z ); }
int CI( int &_a, int &_b, int &_c, int &_d ) { return scanf( "%d %d %d %d", &_a, &_b, &_c, &_d ); }

template <class T> string toString( T n ) { ostringstream oss; oss << n; return oss.str(); }
int toInt( string s ) { int r = 0; istringstream sin( s ); sin >> r; return r; }
i64 toLong( string s ) { i64 r = 0; istringstream sin( s ); sin >> r; return r; }
bool isVowel( char ch ) { ch = tolower( ch ); if( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )return true; return false; }
bool isUpper( char c ) { return c >= 'A' && c <= 'Z'; }
bool isLower( char c ) { return c >= 'a' && c <= 'z'; }

int dr8[8] = { +1, -1, +0, +0, +1, -1, -1, +1};   ///8 direction move
int dc8[8] = { +0, +0, -1, +1, +1, +1, -1, -1};
int dr4[4] = { +0, +0, +1, -1};                   ///4 direction move
int dc4[4] = { -1, +1, +0, +0};                   ///or adjacent dir.
int kn8r[8] = { +1, +2, +2, +1, -1, -2, -2, -1};  ///knight moves
int kn8c[8] = { +2, +1, -1, -2, -2, -1, +1, +2};

const double EPS = 1e-9;                         ///constants
const int INF = ( 1 << 30 ) - 1;
const i64 LINF = ( 1ll << 62 ) - 1;
const int mod = ( int )1e9 + 7;
const int MAX = ( int )1e5;
///____________________________Main Coding Starts From Here________________________///

i64 fact[MAX + 7];
i64 inv[MAX + 7];
i64 partial_pascal[111][MAX + 7];

void Hmm() {
    fact[0] = 1LL;
    inv[0] = ModInv( fact[0], ( i64 )mod );
    for( int i = 1; i <= MAX; i++ ) {
        fact[i] = ( fact[i - 1] * i ) % mod;
        inv[i] = ModInv( fact[i], ( i64 )mod );
        //if( i < 11 )debug( i, fact[i], inv[i] );
    }
}

i64 nCr( int n, int c ) {
    return ( ( ( fact[n] * inv[c] ) % mod ) * inv[n - c] ) % mod;
}

int main() {
#ifndef ONLINE_JUDGE
    READ( "/home/sonjoy/Desktop/in.txt" );
//    WRITE("out.txt");
    deb_mode = 1;
#endif
    if( deb_mode )
        srand( int( time( NULL ) ) );

    int i, j, k, l, r, n, m, q, a, b, c;
    Hmm();

    int ar[MAX + 7];
    CI( n, q );
    rep1( i, n )CI( ar[i] );

    while( q-- ) {
        CI( l, r, k );
        partial_pascal[k][l] += 1LL;
        for( i = k; i >= 0; i-- ) {
            int pop = nCr( r - l + k - i, k - i );
            //debug( i, r - l  + k - i, k - i, pop );
            partial_pascal[i][r + 1] -= nCr( r - l  + k - i, k - i );
            partial_pascal[i][r+1]+=mod;
            partial_pascal[i][r+1]%=mod;

        }
    }

//    rep0( i, 15 ) {
//        rep0( j, 15 )
//        cout << "[" << partial_pascal[i][j] << "] ";
//        nln;
//    }
//    nln;
//    nln;
//    nln;

    for( i = 100; i >= 0; i-- ) {
        for( j = 1; j <= n; j++ ) {
            //cout<<"[ "<<partial_pascal[i][j]<<" ";
            partial_pascal[i][j] = ( partial_pascal[i][j] + partial_pascal[i + 1][j] + partial_pascal[i][j - 1] + mod ) % mod;
            //cout<<partial_pascal[i][j]<<" ] ";
        }
//        int ii, jj;
//        rep0( ii, 15 ) {
//            rep0( jj, 15 )
//            cout << "[" << partial_pascal[ii][jj] << "] ";
//            nln;
//        }
    }

//    rep0( i, 15 ) {
//        rep0( j, 15 )
//        cout << "[" << partial_pascal[i][j] << "] ";
//        nln;
//    }

    rep1( i, n ) {
        cout << ( ar[i] + partial_pascal[0][i] ) % mod;
        if( i == n )nln;
        else spc;
    }

    if( deb_mode )
        cerr << "TIME = " << clock() << " ms" << endl;
    return 0;
}