#include using namespace std; typedef long long ll; #define REP(i, x, y) for (auto i = (x); i < (y); i++) #define RREP(i, x, y) for (auto i = (y) - 1; (x) <= i; i--) #define ALL(x) (x).begin(), (x).end() #pragma GCC optimize("O3") #include using namespace atcoder; int op(int a, int b){ return min(a, b); } int e(){ return 1000000; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector A(N); REP(i, 0, N){ cin >> A[i]; } if(M == 0){ REP(i, 0, N){ cout << N - i << "\n"; } return 0; } vector ans(N); segtree st(M); REP(i, 0, M){ st.set(i, 0); } int j = 0; REP(i, 0, N){ while(st.prod(0, M) == 0 && j < N){ if(A[j] < M){ st.set(A[j], st.get(A[j])+1); } j++; } if(st.prod(0, M) != 0){ ans[j-i-1]++; if(i){ ans[N-i]--; } } if(A[i] < M){ st.set(A[i], st.get(A[i])-1); } // REP(j, 0, M){ // cout << st.get(j) << " "; // } // cout << " " << st.prod(0, M) << "\n"; } // REP(i, 0, N){ // cout << ans[i] << " "; // } // cout << "\n"; ll sum = 0; REP(i, 0, N){ sum += ans[i]; cout << sum << "\n"; } return 0; } /* File : ~/yukicoder/midoriika_3rd/L.cpp Date : 2024/10/12 Time : 16:21:06 */