#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif

#include <bits/stdc++.h>


#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;

using namespace std;

template<class T>
using V = vector<T>;
template<class T>
using VV = V<V<T>>;

using ld = long double;
using ll = long long;
using PLL = pair<ll, ll>;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<ll>;
using VVI = VV<int>;
using VVLL = VV<ll>;
using Gr = VVI;
using MLL = map<ll, ll>;
#define UMLL unordered_map<ll, ll, custom_hash>

#define fast ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);

#define CR const&

#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)

#ifdef LOCAL
#define OK cerr << "OK" << endl;
#else
#define OK
#endif

template<class T>
T sqr(T x) {
    return x * x;
}

template<class T, class U = T>
void cmin(T &a, U const &b) {
    if (b < a)
        a = b;
}

template<class T, class U = T>
void cmax(T &a, U const &b) {
    if (a < b)
        a = b;
}

#ifdef LOCAL

void print_raw() {}

template<class T>
void print_raw(T CR);

void print_raw(string CR);

template<class T, class U>
void print_raw(pair<T, U> CR);

template<ranges::range T>
void print_raw(T CR);

void print_raw(const char *);


template<class T>
void print_raw(T CR t) {
    cerr << t << " ";
}

void print_raw(string CR t) {
    cerr << t << " ";
}

template<class T, class U>
void print_raw(pair<T, U> CR t) {
    cerr << '{';
    print_raw(t.first);
    cerr << "\b, ";
    print_raw(t.second);
    cerr << "\b} ";
}

template<ranges::range T>
void print_raw(T CR t) {
    cerr << '{';

    for (auto i: t)
        print_raw(i);
    if (!empty(t))
        cerr << '\b';

    cerr << "} ";
}

void print_raw(const char *t) {
    if (!t)
        return; //?

    auto sz = strlen(t);
    cerr << t;
    if (sz == 0 || t[sz - 1] != '\n')
        cerr << ' ';
}

template<class T, class... Ts>
void print_raw(T CR t, Ts CR...vals) {
    print_raw(t);
    print_raw(vals...);
}

template<class... Ts>
void print(Ts CR...vals) {
    print_raw(vals...);
    cerr << '\n';
}

#else

template<class... Ts>
void print_raw(Ts CR...vals) {}

template<class... Ts>
inline void print(Ts CR...vals) {}

#endif

template<class T>
void show(T CR t, ostream &os = cerr) {
    for (auto CR i: t)
        os << i << " ";
    os << "\n";
}

template<class T>
void show2d(T CR t, ostream &os = cerr) {
    for (auto CR i: t)
        show(i, os);
    os << "\n";
}

constexpr ll MOD = 1e9 + 7;

constexpr ll INF = 1e16;

const ld PI = atanl(1.0L) * 4;
constexpr ld eps = 1e-6, EPS = 1e-9;

//https://codeforces.com/blog/entry/62393
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<class T>
T &addfix(T &x, ll mod = MOD) {
    if (x >= mod)
        x -= mod;
    return x;
}

template<class T>
T &subfix(T &x, T mod = MOD) {
    if (x < 0)
        x += mod;
    return x;
}

template<class T>
T &afix(T &x, ll mod = MOD) {
    if (x < 0)
        x += mod;
    else if (x >= mod)
        x -= mod;
    return x;
}

template<class T>
T &fix(T &x, T mod = MOD) {
    x %= mod;
    subfix(x, mod);
    return x;
}

ll qpow(ll a, ll b, ll mod = MOD) {
    ll res = 1;
    while (b) {
        if (b & 1LL)
            res = res * a % mod;

        b >>= 1LL;
        a = sqr(a) % mod;
    }

    return res;
}

ll inv(ll a, ll mod = MOD) {
    return qpow(a, mod - 2, mod);
}

ll rand(ll l, ll r) {
    return rand() % (r - l + 1) + l;
}

void init() {}

void solve(int test_id) {
    int n, k;
    cin >> n >> k;

    VI a(n);
    for(auto& i : a) {
        cin >> i;
        --i;
    }

    VI rev(n);
    for(int i = 0; i < n; ++i)
        rev[a[i]] = i;

//    print(rev);

    ll ans = (ll)(k / n) * ((ll)n * (n + 1) / 2);
    k %= n;

    for(int x = 0; x < n; ++x) {
        ll res = ans;
        for(int i = 0, p = rev[x]; i < k; ++i, p = rev[p]) {
            res += p + 1;
        }
        cout << res << " ";
    }
    cout << "\n";
}

int main() {
    auto seed = time(nullptr);
    //cerr << "seed: " << seed << "\n";
    srand(seed);
    fast
    init();
    int q = 1;
//    cin >> q;

    cout << setprecision(999);
    for (int id = 1; id <= q; ++id)
        solve(id);
}