#include <bits/stdc++.h>
using namespace std;
long long mod=998244353,n,v[300002],sp[300002];

long long put (long long baza,long long exp)
{
    long long sol=1;
    while (exp!=0)
    {
        if (exp%2==1)
            {
                sol=sol*baza;
                sol%=mod;
            }
        baza=baza*baza;
        baza%=mod;
        exp/=2;
    }
    return sol;
}

int main()
{
    cin>>n;
    long long i,k,invers=put (n,mod-2);
    for (i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1,greater<long long>());
    for (i=1;i<=n;i++)
        sp[i]=sp[i-1]+v[i];
    for (k=1;k<=n;k++)
    {
        long long sol=0,cnt=1;
        for(i=2*k;i<=n;i+=k)
            sol=sol+cnt*(sp[i]-sp[i-k]),cnt++;
        sol+=cnt*(sp[n]-sp[i-k]);
        sol%=mod;
        sol=sol*1LL*invers;
        sol%=mod;
        cout<<sol<<' ';
    }
    return 0;
}


/*
 * Author: andyli
 * Time: 2020-07-13 19:55:05
**/

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <random>

#ifndef LX_DEBUG
// #define LX_DEBUG
#endif

#if defined(__unix__) && !defined(LX_DEBUG) && !defined(LX_LOCAL)
#define USE_MMAP 1
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#else
#define USE_MMAP 0
#endif

using LL = long long;
using ULL = unsigned long long;
#ifdef __SIZEOF_INT128__
#define USE_INT128
using LLL = __int128;
using ULLL = unsigned __int128;
#else
using LLL = long long;
using ULLL = unsigned long long;
#endif
using LD = long double;
#if defined(__SIZEOF_FLOAT128__) && !defined(LX_LOCAL)
using LLD = __float128;
#else
using LLD = long double;
#endif

namespace std {
#define def(type) \
    void swap(type& x, type& y) { x ^= y, y ^= x, x ^= y; }
    def(char);
    def(signed char);
    def(unsigned char);
    def(short);
    def(unsigned short);
    def(int);
    def(unsigned int);
    def(LL);
    def(ULL);
#ifdef __SIZEOF_INT128__
    def(LLL);
    def(ULLL);
#endif
#undef def
};  // namespace std

#ifdef LX_LOCAL
#include <ctime>
class Time {
public:
    clock_t begin;
    Time() { begin = clock(); }
    ~Time() {
        double t = (clock() - begin) * 1000.0 / static_cast<double>(CLOCKS_PER_SEC);
        fprintf(stderr, "Time used = ");
        if (t >= 60000)
            fprintf(stderr, "%.2lfmin\n", t / 60000.0);
        else if (t >= 1000)
            fprintf(stderr, "%.2lfs\n", t / 1000.0);
        else
            fprintf(stderr, "%.0lfms\n", t);
    }
} timeout;
#endif

template <typename T>
struct make_unsigned : public std::make_unsigned<T> {};
template <>
struct make_unsigned<LLL> { typedef ULLL type; };

using std::swap;
#if __cplusplus >= 201402L
template <typename T, typename P>
inline constexpr auto max(const T& x, const P& y) { return x < y ? y : x; }
template <typename T, typename P>
inline constexpr auto min(const T& x, const P& y) { return x < y ? x : y; }
template <typename T, typename... Args>
inline constexpr auto max(const T& x, const Args&... args) { return max(x, max(args...)); }
template <typename T, typename... Args>
inline constexpr auto min(const T& x, const Args&... args) { return min(x, min(args...)); }
#else
template <typename T, typename P>
inline constexpr auto max(const T& x, const P& y) -> decltype(x < y ? y : x) { return x < y ? y : x; }
template <typename T, typename P>
inline constexpr auto min(const T& x, const P& y) -> decltype(x < y ? x : y) { return x < y ? x : y; }
template <typename T, typename... Args>
inline constexpr auto max(const T& x, const Args&... args) -> decltype(max(x, max(args...))) { return max(x, max(args...)); }
template <typename T, typename... Args>
inline constexpr auto min(const T& x, const Args&... args) -> decltype(min(x, min(args...))) { return min(x, min(args...)); }
#endif
template <typename T>
inline constexpr T max(const T& x) { return x; }
template <typename T>
inline constexpr T min(const T& x) { return x; }
template <typename T, typename... Args>
inline void chkmax(T& d, const Args&... args) { d = max(d, args...); }
template <typename T, typename... Args>
inline void chkmin(T& d, const Args&... args) { d = min(d, args...); }

#define lc (o << 1)
#define rc (o << 1 | 1)
#define lowbit(x) ((x) & (-(x)))
#define ALL(x) std::begin(x), std::end(x)
#define SZ(x) int(x.size())

std::mt19937 mrand(std::random_device{}());
std::mt19937_64 mrand64(std::random_device{}());

#pragma region IO
constexpr size_t bufSize = 1 << 20;

class In {
private:
    FILE* inFile = nullptr;
    bool status = true;
#if USE_MMAP
    struct stat st;
    char* ptr;
    int fd;
    size_t pos;
#elif !defined(LX_DEBUG)
    char buf[bufSize], *p1, *p2;
#endif
public:
#ifdef LX_DEBUG
    inline int getch() { return fgetc(inFile); }
    inline void putback(char c) { ungetc(c, inFile); }
    inline void input(FILE* f) { inFile = f, setStatus(true); }
    inline void input(const char* str) { inFile = fopen(str, "rb"), setStatus(true); }
#elif USE_MMAP
    inline int getch() { return *(ptr + pos) ? *(ptr + (pos++)) : (setStatus(false), EOF); }
    inline void putback(char) { pos--; }
    inline void input(FILE* f) {
        if ((inFile = f))
            fd = fileno(inFile), fstat(fd, &st), ptr = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0), pos = 0;
        setStatus(true);
    }
    inline void input(const char* str) { fd = open(str, O_RDONLY), fstat(fd, &st), ptr = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0), pos = 0, setStatus(true); }
#else
    inline int getch() { return (p1 == p2 ? (p2 = (p1 = buf) + fread(buf, 1, bufSize, inFile)) : 0), (p1 == p2) ? (setStatus(false), EOF) : *p1++; }
    inline void putback(char c) { *(--p1) = c; }
    inline void input(FILE* f) { inFile = f, p1 = p2 = buf, setStatus(true); }
    inline void input(const char* str) { inFile = fopen(str, "rb"), p1 = p2 = buf, setStatus(true); }
#endif
    inline void setStatus(bool status) { this->status = status; }
    inline bool getStatus() const { return status; }
};
class Out {
private:
    FILE* outFile = nullptr;
#ifndef LX_DEBUG
    char pbuf[bufSize], *pp;
#endif
public:
#ifdef LX_DEBUG
    inline void flush() { outFile ? fflush(outFile) : 0; }
    inline void putch(const char c) { fputc(c, outFile); }
#else
    inline void flush() { (outFile ? fwrite(pbuf, 1, pp - pbuf, outFile), fflush(outFile) : 0), pp = pbuf; }
    inline void putch(const char c) { ((pp - pbuf == bufSize) ? fwrite(pbuf, 1, bufSize, outFile), pp = pbuf : 0), *pp++ = c; }
#endif
    inline void output(const char* str) { flush(), outFile = fopen(str, "wb"); }
    inline void output(FILE* f) { flush(), outFile = f; }
};
class IO : public In, public Out {
private:
    long double eps = 1e-8L;
    LLL pow10 = 1000000;
    size_t precision = 6;

public:
    IO(FILE* = nullptr, FILE* = nullptr);
    ~IO();
    inline void flush();
    inline static constexpr bool blank(char);
    template <typename T, typename... Args>
    IO& read(T&, Args&...);
    template <typename T>
    typename std::enable_if<(std::is_signed<T>::value && std::is_integral<T>::value) || std::is_same<typename std::remove_cv<T>::type, LLL>::value, IO&>::type read(T&);
    template <typename T>
    typename std::enable_if<(std::is_unsigned<T>::value && std::is_integral<T>::value) || std::is_same<typename std::remove_cv<T>::type, ULLL>::value, IO&>::type read(T&);
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value, IO&>::type read(T&);
    template <typename T>
    typename std::enable_if<std::is_integral<T>::value || std::is_floating_point<T>::value || std::is_same<typename std::remove_cv<T>::type, LLL>::value || std::is_same<typename std::remove_cv<T>::type, ULLL>::value, T>::type read();
    IO& read(char&);
    IO& read(char*);
    IO& readline(char*);
    inline void setprecision(size_t = 6u);
    template <typename T, typename... Args>
    void write(const T&, const Args&...);
    inline void write() const {}
    template <typename T>
    typename std::enable_if<(std::is_signed<T>::value && std::is_integral<T>::value) || std::is_same<T, LLL>::value, void>::type write(T);
    template <typename T>
    typename std::enable_if<(std::is_unsigned<T>::value && std::is_integral<T>::value) || std::is_same<T, ULLL>::value, void>::type write(T);
    inline void write(char);
    template <typename T>
    typename std::enable_if<std::is_floating_point<T>::value, void>::type write(T);
    inline void write(bool);
    void write(char*);
    void write(const char*);
    template <typename... Args>
    void writeln(Args...);
    template <typename Iter>
    IO& readArray(Iter, Iter);
    template <typename Iter>
    void displayArray(Iter, Iter, char = ' ');
    operator bool() const { return getStatus(); }
} io(stdin, stdout), err(nullptr, stderr);
template <typename Func>
void multipleTests(Func&&, IO& = io);
template <typename... Args>
inline void writeln(Args... x) { io.write(x...), io.putch('\n'); }
#define dbg(x) err.write(#x " = "), err.writeln(x)
#pragma endregion IO
constexpr int maxn = 300005;

template <int _mod>
struct Int {
    static constexpr int MOD = _mod;
    int v = 0;
    Int() {}
    template <typename T>
    Int(T _v) { *this = _v; }
    Int(const Int& v) : v(v.v) {}
    template <typename T>
    Int& operator=(T _v) {
        v = (-MOD < _v && _v < MOD) ? _v : (MOD <= _v && _v < (MOD << 1) ? _v - MOD : _v % MOD);
        if (v < 0)
            v += MOD;
        return *this;
    }
    Int& operator=(const Int& v) {
        this->v = v.v;
        return *this;
    }
    template <typename T>
    inline static Int quick_pow(Int a, T n) {
        Int ans = 1;
        while (n) {
            if (n & 1)
                ans *= a;
            a *= a;
            n >>= 1;
        }
        return ans;
    }
    inline static Int inv(Int v) { return quick_pow(v, MOD - 2); }
    friend inline int mod(int v) { return v + (v >> 31 & MOD); }
    friend inline void mod(int& v) { v += v >> 31 & MOD; }
    inline bool operator<(const Int& rhs) const { return v < rhs.v; }
    inline bool operator>(const Int& rhs) const { return v > rhs.v; }
    inline bool operator<=(const Int& rhs) const { return v <= rhs.v; }
    inline bool operator>=(const Int& rhs) const { return v >= rhs.v; }
    inline bool operator==(const Int& rhs) const { return v == rhs.v; }
    inline bool operator!=(const Int& rhs) const { return v != rhs.v; }
    inline Int operator+(const Int& rhs) const { return Int(v + rhs.v - MOD); }
    inline Int operator-(const Int& rhs) const { return Int(v - rhs.v); }
    inline Int operator*(const Int& rhs) const { return Int((long long)v * rhs.v); }
    inline Int operator/(const Int& rhs) const { return operator*(inv(rhs)); }
    inline Int operator+=(const Int& rhs) { return *this = *this + rhs; }
    inline Int operator-=(const Int& rhs) { return *this = *this - rhs; }
    inline Int operator*=(const Int& rhs) { return *this = *this * rhs; }
    inline Int operator/=(const Int& rhs) { return *this = *this / rhs; }
    inline Int operator-() const { return Int(-v); }
    inline Int& operator++() { return *this += 1; }
    inline Int& operator--() { return *this -= 1; }
    inline Int operator++(int) {
        const Int r = *this;
        *this += 1;
        return r;
    }
    inline Int operator--(int) {
        const Int r = *this;
        *this -= 1;
        return r;
    }
};

using INT = Int<998244353>;
LL A[maxn];
INT ans[maxn];
int main() {
    int n;
    io.read(n).readArray(A + 1, A + n + 1);
    std::sort(A+1, A+n+1);
    for (int i = 2; i <= n; i++)
        A[i] += A[i - 1];
    for (int i = 1; i < n; i++)
        for (int j = i; j >= 1; j -= (n - i))
            ans[i] += A[j];
    for (int i = n - 1; i >= 0; i--)
        io.write((ans[i]/n).v, " \n"[i == n]);
    return 0;
}

#define isdigit(x) (x >= '0' && x <= '9')
IO::IO(FILE* in, FILE* out) { input(in), output(out); }
IO::~IO() { flush(); }
inline void IO::flush() { Out::flush(); }
inline constexpr bool IO::blank(char ch) { return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'; }
template <typename T, typename... Args>
IO& IO::read(T& x, Args&... args) {
    if (read(x))
        return sizeof...(args) ? read(args...) : *this;
    return *this;
}
template <typename T>
typename std::enable_if<(std::is_signed<T>::value && std::is_integral<T>::value) || std::is_same<typename std::remove_cv<T>::type, LLL>::value, IO&>::type IO::read(T& x) {
    static typename make_unsigned<T>::type _tmp;
    bool sign = false;
    int ch = getch();
    while (!isdigit(ch) && ~ch)
        sign = (ch == '-'), ch = getch();
    if (!(~ch))
        return setStatus(false), *this;
    _tmp = 0;
    while (isdigit(ch))
        _tmp = (_tmp << 1) + (_tmp << 3) + (ch ^ '0'), ch = getch();
    if (~ch)
        putback(ch);
    x = sign ? (~_tmp + 1) : _tmp;
    return *this;
}
template <typename T>
typename std::enable_if<(std::is_unsigned<T>::value && std::is_integral<T>::value) || std::is_same<typename std::remove_cv<T>::type, ULLL>::value, IO&>::type IO::read(T& x) {
    int ch = getch();
    while (!isdigit(ch) && ~ch)
        ch = getch();
    if (!(~ch))
        return setStatus(false), *this;
    x = 0;
    while (isdigit(ch))
        x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getch();
    if (~ch)
        putback(ch);
    return *this;
}
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value, IO&>::type IO::read(T& x) {
    x = 0;
    T tmp = 1;
    bool sign = false;
    int ch = getch();
    while (!isdigit(ch) && ~ch)
        sign = (ch == '-'), ch = getch();
    if (!(~ch))
        return setStatus(false), *this;
    while (isdigit(ch))
        x = x * 10 + (ch ^ '0'), ch = getch();
    if (ch == '.')
        for (ch = getch(); isdigit(ch); ch = getch())
            x += (tmp /= 10.0) * (ch ^ '0');
    if (~ch)
        putback(ch);
    x = sign ? (-x) : x;
    return *this;
}
template <typename T>
typename std::enable_if<std::is_integral<T>::value || std::is_floating_point<T>::value || std::is_same<typename std::remove_cv<T>::type, LLL>::value || std::is_same<typename std::remove_cv<T>::type, ULLL>::value, T>::type IO::read() {
    static typename std::remove_cv<T>::type x;
    return read(x), x;
}
IO& IO::read(char& ch) {
    do
        ch = getch();
    while (blank(ch) && ~ch);
    if (ch == -1)
        setStatus(false);
    return *this;
}
IO& IO::read(char* s) {
    int ch = getch();
    while (blank(ch))
        ch = getch();
    if (!(~ch))
        return setStatus(false), *this;
    while (!blank(ch) && ~ch)
        *s++ = ch, ch = getch();
    *s = 0;
    if (~ch)
        putback(ch);
    return *this;
}
IO& IO::readline(char* s) {
    int ch = getch();
    while (blank(ch) && (ch ^ '\n'))
        ch = getch();
    if (!(~ch))
        return setStatus(false), *this;
    while ((ch ^ '\n') && ~ch)
        *s++ = ch, ch = getch();
    *s = 0;
    return *this;
}
inline void IO::setprecision(size_t n) {
    precision = n;
    eps = powl(10.0L, -int(precision) - 2);
    pow10 = powl(10.0L, precision) + eps;
}
template <typename T, typename... Args>
void IO::write(const T& x, const Args&... args) {
    write(x);
    if (sizeof...(args))
        write(args...);
}
template <typename T>
typename std::enable_if<(std::is_signed<T>::value && std::is_integral<T>::value) || std::is_same<T, LLL>::value, void>::type IO::write(T x) {
    if (x < 0)
        x = ~x + 1, putch('-');
    static int sta[40], top = 0;
    do
        sta[top++] = x % 10, x /= 10;
    while (x);
    while (top)
        putch(sta[--top] ^ '0');
}
template <typename T>
typename std::enable_if<(std::is_unsigned<T>::value && std::is_integral<T>::value) || std::is_same<T, ULLL>::value, void>::type IO::write(T x) {
    static int sta[40], top = 0;
    do
        sta[top++] = x % 10, x /= 10;
    while (x);
    while (top)
        putch(sta[--top] ^ '0');
}
inline void IO::write(bool x) { putch(x ^ 48); }
inline void IO::write(char c) { putch(c); }
template <typename T>
typename std::enable_if<std::is_floating_point<T>::value>::type IO::write(T x) {
    if (x == 0) {
        putch('0'), putch('.');
        for (size_t i = 1; i <= precision; i++)
            putch('0');
        return;
    }
    if (x < 0)
        putch('-'), x = -x;
    T res = (LLL)(x * pow10 + 0.5) / (pow10 * 1.0);
    LLL y = LLL(res * pow10 + eps) % pow10;
    write(LLL(res + eps));
    if (precision) {
        putch('.');
        static size_t sta[100], p = 0;
        while (p < precision && y)
            sta[++p] = y % 10, y /= 10;
        while (p < precision)
            sta[++p] = 0;
        while (p)
            putch(sta[p--] ^ 48);
    }
}
void IO::write(char* s) {
    while (*s)
        putch(*s++);
}
void IO::write(const char* s) {
    while (*s)
        putch(*s++);
}
template <typename... Args>
void IO::writeln(Args... x) { write(x...), putch('\n'); }
template <typename Iter>
IO& IO::readArray(Iter first, Iter last) {
    if (first == last)
        return *this;
    Iter cur = first;
    bool r = true;
    while (cur != last && r)
        r &= read(*cur++);
    if (!r)
        setStatus(false);
    return *this;
}
template <typename Iter>
void IO::displayArray(Iter first, Iter last, char delim) {
    if (first == last)
        return putch('\n');
    for (Iter cur = first; cur != last;) {
        write(*cur);
        if (++cur != last)
            putch(delim);
    }
    putch('\n');
}
template <typename Func>
void multipleTests(Func&& f, IO& _io) {
    int q;
    _io.read(q);
    for (int i = 1; i <= q; i++)
        f();
}
#undef isdigit


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

namespace snippets_modular {
    template <class C>
    struct Modular {
        using I = decltype(C::m());
        I val = 0;

    private:
#ifdef __SIZEOF_INT128__
        using Mul = conditional_t<sizeof(I) >= 5, unsigned __int128, uint64_t>;
#else
        static_assert(sizeof(I) <= 4, "cannot multiply larger than 64-bit");
        using Mul = uint64_t;
#endif

        struct Unchecked {};
        constexpr Modular(I _val, Unchecked) : val(_val) {}
        static constexpr array<I, 3> ext_gcd(I a, I b) {
            if (!a) return {b,0,1};
            auto ar = ext_gcd(b % a, a);
            return {ar[0], ar[2] - (b / a) * ar[1], ar[1]};
        }
    public:

        constexpr Modular() = default;
        template <class T>
        constexpr Modular(T _val) { _val %= C::m(); if (_val < 0) _val += C::m(); val = static_cast<I>(_val); }

        template <class T>
        constexpr explicit operator T() const { return static_cast<T>(val); }

#define DEFINE_CMP(op) constexpr bool operator op (Modular r) const { return val op r.val; }
        DEFINE_CMP(==) DEFINE_CMP(!=) DEFINE_CMP(<) DEFINE_CMP(<=) DEFINE_CMP(>) DEFINE_CMP(>=)
#undef DEFINE_CMP

        constexpr Modular& operator+=(Modular r) { if ((val += r.val) >= C::m()) val -= C::m(); return *this; }
        constexpr Modular& operator-=(Modular r) { if (r.val > val) val += C::m(); val -= r.val; return *this; }
        template <class T> constexpr enable_if_t<is_integral<T>::value, Modular&> operator+=(T r) { return *this += Modular(r); }
        template <class T> constexpr enable_if_t<is_integral<T>::value, Modular&> operator-=(T r) { return *this -= Modular(r); }
        constexpr Modular operator+(Modular r) const { return Modular(*this) += r; }
        constexpr Modular operator-(Modular r) const { return Modular(*this) -= r; }

        constexpr Modular operator*(Modular r) const { return Modular(static_cast<Mul>(val) * static_cast<Mul>(r.val)); }
        constexpr Modular& operator*=(Modular r) { return *this = *this * r; }
        template <class T> constexpr enable_if_t<is_integral<T>::value, Modular&> operator*=(T r) { return *this *= Modular(r); }

        template <class T> constexpr Modular pow(T e) const {
            Modular a = 1, b = *this;
            for (; e > 0; b *= b, e /= 2)
                if (e % 2) a *= b;
            return a;
        }
        constexpr Modular inv() const { I x = ext_gcd(val, C::m())[1]; return Modular(x < 0 ? x + C::m() : x, Unchecked{}); }

        constexpr Modular& operator/=(Modular r) { return *this *= r.inv(); }
        template <class T> constexpr enable_if_t<is_integral<T>::value, Modular&> operator/=(T r) { return *this /= Modular(r); }
        constexpr Modular operator/(Modular r) const { return Modular(*this) /= r; }

        constexpr Modular operator+() const { return *this; }
        constexpr Modular operator-() const { return Modular(val ? -val + C::m() : val, Unchecked{}); }
        constexpr Modular& operator++() { return *this += 1; }
        constexpr Modular& operator--() { return *this -= 1; }
        constexpr Modular operator++(int) { auto r = *this; *this += 1; return r; }
        constexpr Modular operator--(int) { auto r = *this; *this -= 1; return r; }
    };

#define DEFINE_OPS(op) \
        template <class C, class T, class = enable_if_t<is_integral<T>::value>> \
        constexpr auto operator op (Modular<C> l, T r) { return Modular<C>(l) op Modular<C>(r); } \
        template <class C, class T, class = enable_if_t<is_integral<T>::value>> \
        constexpr auto operator op (T l, Modular<C> r) { return Modular<C>(l) op Modular<C>(r); }
    DEFINE_OPS(==) DEFINE_OPS(!=) DEFINE_OPS(<) DEFINE_OPS(<=) DEFINE_OPS(>) DEFINE_OPS(>=)
    DEFINE_OPS(+) DEFINE_OPS(-) DEFINE_OPS(*) DEFINE_OPS(/)
#undef DEFINE_OPS

    template<class C> std::ostream& operator<<(std::ostream& out, Modular<C> m) { return out << m.val; }
    template <class C> std::istream& operator>>(std::istream& in, Modular<C>& m) {
        // Avoid reading character types
        using I = typename Modular<C>::I;
        using T = conditional_t<is_same<I, signed char>::value || is_same<I, unsigned char>::value || is_same<I, char>::value, int, I>;

        T val{};
        in >> val;
        m = Modular<C>(val);
        return in;
    }
    template<class C> string to_string(Modular<C> m) { return ::to_string(m.val); }

    template <class I, I M> struct ConstMod { static constexpr I m() { return M; } };
    using MI = Modular<ConstMod<int, 998244353>>;
    using vMI = vector<MI>;

    MI operator ""_mi(unsigned long long i) { return MI(i); }
}
using namespace snippets_modular;
namespace std {
    template <class C> struct hash<Modular<C>> {
        size_t operator()(Modular<C> m) const { return hash<typename Modular<C>::I>()(m.val); }
    };
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vi c(n);
    trav(ci, c) cin >> ci;
    sort(all(c), greater<>());

    vMI a(n, c[0]);
    reps(i, 1, n)
        a[i] = a[i-1] + c[i];

    MI ni = MI(n).inv();
    reps(k, 1, n + 1) {
        MI res = 0;
        reps(i, 1, n) {
            int l = k * i;
            if (l >= n) break;
            int r = min(l + k, n);
            res += (a[r-1] - a[l-1]) * i * ni;
        }
        cout << res << ' ';
    }

    cout << '\n';
    return 0;
}


    #include <bits/stdc++.h>

    using namespace std;
    typedef long long ll;

    const ll MOD = 998244353;

    ll C[303030];
    ll S[303030];
    int N;

    ll pw(ll a, ll b) {
    	ll ret = 1;
    	while(b) {
    		if(b & 1) ret = ret * a % MOD;
    		a = a * a % MOD;
    		b >>= 1;
    	}
    	return ret;
    }
    ll inv(ll x) { return pw(x, MOD - 2); }

    int main() {
    	scanf("%d", &N);
    	for(int i = 1; i <= N; i++) scanf("%lld", &C[i]);
    	sort(C + 1, C + N + 1);

    	for(int i = 1; i <= N; i++) S[i] = S[i - 1] + C[i];

    	ll I = inv(N);

    	for(int i = 1; i <= N; i++) {
    		ll ans = 0;
    		for(int j = N - i; j >= 1; j -= i) ans = (ans + S[j]) % MOD;
    		printf("%lld ", ans * I % MOD);
    	}
    	puts("");

    	return 0;
    }


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,greater<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(a.begin(),a.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll inv(ll n, ll p)
{
    return power(n, p-2, p);
}

int main()
{
    FAST;
    ll n,te;
    cin>>n;
    te=inv(n,B);
    ve<ll> a(n),pref(n,0);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sorrev(a);
    pref[0]=a[0];
    for(ll i=1;i<n;i++)
        pref[i]=(pref[i-1]+a[i])%B;
    for(ll i=1;i<=n;i++)
    {
        ll ans=0;
        for(ll j=0,l=0,r=i-1;j<(n/i);j++,l+=i,r+=i)
        {
            ll x=(j*(pref[r]-((l!=0)?pref[l-1]:0)))%B;
            ans=(ans+x)%B;
        }
        if(n%i!=0 && (n/i)!=0)
        {
            ll x=((n/i)*(pref[n-1]-pref[n-(n%i)-1]))%B;
            ans=(ans+x)%B;
        }
        cout<<(ans*te)%B<<' ';
    }
    subt;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,greater<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(a.begin(),a.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll inv(ll n, ll p)
{
    return power(n, p-2, p);
}

int main()
{
    FAST;
    ll n,te;
    cin>>n;
    te=inv(n,B);
    ve<ll> a(n),pref(n,0);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    sorrev(a);
    pref[0]=a[0];
    for(ll i=1;i<n;i++)
        pref[i]=(pref[i-1]+a[i])%B;
    for(ll i=1;i<=n;i++)
    {
        ll ans=0;
        for(ll j=0,l=0,r=i-1;j<(n/i);j++,l+=i,r+=i)
        {
            ll x=(j*(pref[r]-((l!=0)?pref[l-1]:0)))%B;
            ans=(ans+x)%B;
        }
        if(n%i!=0 && (n/i)!=0)
        {
            ll x=((n/i)*(pref[n-1]-pref[n-(n%i)-1]))%B;
            ans=(ans+x)%B;
        }
        ans=(ans+B)%B;
        cout<<(ans*te)%B<<' ';
    }
    subt;
    return 0;
}


#include <bits/stdc++.h>
constexpr int P = 998244353;
int power(int a, int b) {
    int res = 1;
    for (; b; b >>= 1, a = 1ll * a * a % P)
        if (b & 1)
            res = 1ll * res * a % P;
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> c(n);
    for (int i = 0; i < n; ++i)
        std::cin >> c[i];
    std::sort(c.begin(), c.end(), std::greater<>());
    std::vector<int> sum(n + 1);
    for (int i = 0; i < n; ++i)
        sum[i + 1] = (sum[i] + c[i]) % P;
    int inv = power(n, P - 2) % P;
    for (int k = 1; k <= n; ++k) {
        int ans = 0;
        for (int i = 0; i * k < n; ++i)
            ans = (ans + 1ll * i * (sum[std::min(n, (i + 1) * k)] - sum[i * k] + P)) % P;
        std::cout << 1ll * inv * ans % P << " \n"[k == n];
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 998244353
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll>
#define vi vector< ll >
#define vvi vector< vi >
#define vpi vector< pii >
#define vvpi vector< vpi >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n;
    cin>>n;
    vi arr(n);
    fr(i,n)cin>>arr[i];
    sort(all(arr));
    ll prefix[n];
    prefix[0] = arr[0];
    rep(i,1,n-1)prefix[i]=prefix[i-1]+arr[i];
    rep(i,1,n)
    {
        ll x,p,ans=0;
        x = (n-i)/i;
        p = i;
        if(n%i)
            x++,p = n%i;
        ans = x*prefix[p-1]%mod;
        x--;
        ll done = p;
        while(x>0){
            ans+=x*(prefix[done+i-1]-prefix[done-1]);
            x--;
            done+=i;
            ans%=mod;
        }
        ans*=power(n,mod-2);
        ans%=mod;
        cout<<ans<<" ";
    }
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 998244353
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll>
#define vi vector< ll >
#define vvi vector< vi >
#define vpi vector< pii >
#define vvpi vector< vpi >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
signed main()
{
    fast;
    ll n;
    cin>>n;
    vi arr(n);
    fr(i,n)cin>>arr[i];
    sort(all(arr));
    ll prefix[n];
    prefix[0] = arr[0];
    rep(i,1,n-1)prefix[i]=prefix[i-1]+arr[i];
    rep(i,1,n)
    {
        ll x,p,ans=0;
        x = (n-i)/i;
        p = i;
        if(n%i)
            x++,p = n%i;
        ans = x*prefix[p-1];
        x--;
        ll done = p;
        while(x>0){
            ans+=x*(prefix[done+i-1]-prefix[done-1]);
            x--;
            done+=i;
            ans%=mod;
        }
        ans*=power(n,mod-2);
        ans%=mod;
        cout<<ans<<" ";
    }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const ll mod = 998244353;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n;
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

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

    ll invn = pw(n,mod-2);

    sort(a,a+n);
    reverse(a,a+n);

    for (int i=1; i<=n+n+10; i++) {
	a[i]+=a[i-1];
	a[i]%=mod;
    }

    for (ll k=1; k<=n; k++) {
	ll res=0;
	for (int i=0; i<n; i+=k) {
	    ll cur=a[i+k-1];
	    if (i>0) cur += (mod-a[i-1]);
	    cur %= mod;
	    res += (1ll*(i/k)*cur%mod);
	    res %= mod;
	}
	res=res*invn%mod;
	cout<<res<<" ";
    }
    cout<<endl;

    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const ll mod = 998244353;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n;
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

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

    ll invn = pw(n,mod-2);

    sort(a,a+n);
    reverse(a,a+n);

    for (ll k=1; k<=n; k++) {
	ll res=0;
	for (int i=0; i<n; i++) {
	    res+=(i/k)*a[i];
	}
	res=res*invn%mod;
	cout<<res<<" ";
    }
    cout<<endl;

    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

using ll = long long;

const ll mod = 998244353;
const int maxn = 1e6 + 5;

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

// note: we can choose where to place the treasure chests, I thought they were given to us arranged....
int n;
ll a[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

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

    ll invn = pw(n,mod-2);

    sort(a,a+n);
    reverse(a,a+n);

    for (int i=1; i<=n+n+10; i++) {
	a[i]+=a[i-1];
	a[i]%=mod;
    }

    // For some k, fit chests into mostly equal segments
    // Obviously, for a segment of length L, we place heavier chests first to the expected chance of us
    // using them is lower.
    for (ll k=1; k<=n; k++) {
	ll res=0;
	for (int i=0; i<n; i+=k) {
	    ll cur=a[i+k-1];
	    if (i>0) cur += (mod-a[i-1]);
	    cur %= mod;
	    res += (1ll*(i/k)*cur%mod);
	    res %= mod;
	}
	res=res*invn%mod;
	cout<<res<<" ";
    }
    cout<<endl;

    return 0;
}


#include <bits/stdc++.h>

const int N = 300010;
const int moder = 998244353;

int a[N];

int powermod(int a, int exp){
    int ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * ret * a % moder;
        }
        a = 1ll * a * a % moder;
    }
    return ret;
}

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
    }
    std::sort(a, a + n, std::greater <int>());
    for (int i = 1; i < n; ++ i){
        a[i] += a[i - 1];
        a[i] -= a[i] >= moder ? moder : 0;
    }
    for (int i = 1; i <= n; ++ i){
        int ans = 0;
        for (int j = 0; j < n; j += i){
            int r = std::min(n - 1, j + i - 1);
            int num = j / i;
            ans = (ans + 1ll * num * (a[r] - (j ? a[j - 1] : 0))) % moder;
        }
        ans += ans < 0 ? moder : 0;
        ans = 1ll * ans * powermod(n, moder - 2) % moder;
        printf("%d%c", ans, " \n"[i == n]);
    }
    return 0;
}


//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
using modint = ModInt< MOD9 >;modint pow(ll n, ll x){return modint(n).pow(x);}modint pow(modint n, ll x){return n.pow(x);}
//using modint=ld;
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  sort(ALLR(a));
  vector<modint>ret(n);
  vector<modint>b(n+1);
  rep(i,0,n)b[i+1]=b[i]+a[i];
  rep(i,1,n+1){
    ll lim=(n+i-1)/i;
    rep(j,0,lim){
      //cout<<i spa j spa i*j spa i*(j-1)<<endl;
      ret[i-1]+=(b[min(n,i*(j+1))]-b[i*j])*j;
    }
  }
  rep(i,0,n)ret[i]/=n;
  debug(ret,n);
  return 0;
}


//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};
using modint = ModInt< MOD9 >;modint pow(ll n, ll x){return modint(n).pow(x);}modint pow(modint n, ll x){return n.pow(x);}
//using modint=ld;
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  sort(ALLR(a));
  vector<modint>ret(n);
  rep(i,0,n)ret[0]+=i*a[i];
  //rep(i,0,n)ret[0]+=i;
  rep(i,0,n){
    ll l=1;
    while(l<=i){
      ll r=i/(i/l)+1;
      ret[r-1]-=(i/l-i/r)*a[i];
      //ret[r-1]-=(i/l-i/r);
      l=r;
    }
  }
  //debug(ret,n);
  rep(i,0,n-1)ret[i+1]+=ret[i];
  rep(i,0,n)ret[i]/=n;
  debug(ret,n);
  return 0;
}


#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 3e5+10, mod = 998244353;
int n,a[N],pre[N];

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline int Mod(int x){
	return x<0?x+mod:x;
}

int main(){
	n=read();
	For(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	For(i,1,n) pre[i]=(pre[i-1]+a[i])%mod;
	int inv=power(n,mod-2);
	For(i,1,n){
		int m=n-i,len=m/i,ans=0;
		//For(j,1,m) printf("%d ",a[j]);puts("");
		for (int l=m%i+1;l<=m;l+=i){
			int r=min(m,l+i-1);
			ans=(ans+1ll*Mod(pre[r]-pre[l-1])*len)%mod;
			--len;
		}
		ans=(ans+1ll*pre[m%i]*(m/i+(m%i>0)))%mod;
		printf("%d ",1ll*ans*inv%mod);
	}
}


#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 3e5+10, mod = 998244353;
int n,a[N],pre[N];

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline int Mod(int x){
	return x<0?x+mod:x;
}

int main(){
	n=read();
	For(i,1,n) a[i]=read();
	sort(a+1,a+1+n);
	For(i,1,n) pre[i]=(pre[i-1]+a[i])%mod;
	int inv=power(n,mod-2);
	For(i,1,n){
		int m=n-i,len=m/i,ans=0;
		if (m%i) ++len;
		for (int l=1;l<=m;l+=i){
			int r=min(m,l+i-1);
			ans=(ans+1ll*Mod(pre[r]-pre[l-1])*len)%mod;
			--len;
		}
		if (i<=m&&m%i) ans=Mod(ans-Mod(pre[i]-pre[m%i]))%mod;
		printf("%d ",1ll*ans*inv%mod);
	}
}


#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define double long double
#define int long long

const int maxn = 3e5 + 1, mod = 998244353;

using namespace std;

int c[maxn];
int pf[maxn];

int bp(int a, int n) {
    if (!n) return 1;
    if (n % 2) return (a * bp(a, n - 1)) % mod;
    return bp((a * a) % mod, n / 2);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c[i];
    sort(c, c + n);
    for (int i = n - 1; i >= 0; i--)
        pf[i] = (pf[i + 1] + c[i]) % mod;
    for (int k = 1; k <= n; k++) {
        int cc = 1;
        int gc = min(k, n - k);
        int ans = 0;
        for (int i = n - k - 1; i >= 0; i -= gc, cc++)
            ans += cc * (pf[max(0ll, i - gc + 1)] - pf[i + 1]);
        ans %= mod;
        ans = (ans + mod) % mod;
        cout << (ans * bp(n, mod - 2)) % mod << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define double long double
#define int long long

const int maxn = 3e5 + 1, mod = 998244353;

using namespace std;

int c[maxn];
int pf[maxn];

int bp(int a, int n) {
    if (!n) return 1;
    if (n % 2) return (a * bp(a, n - 1)) % mod;
    return bp((a * a) % mod, n / 2);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c[i];
    sort(c, c + n);
    for (int i = n - 1; i >= 0; i--)
        pf[i] = (pf[i + 1] + c[i]) % mod;
    for (int k = 1; k <= n; k++) {
        int cc = 1;
        int gc = min(k, n - k);
        int ans = 0;
        for (int i = n - k - 1; i >= 0; i -= gc, cc++)
            ans += cc * (pf[max(0ll, i - gc + 1)] - pf[i + 1]);
        ans %= mod;
        cout << (ans * bp(n, mod - 2)) % mod << ' ';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int mod = 998244353;

int mul(int a, int b) {
    return (a * 1ll * b) % mod;
}

int summ(int a, int b) {
    a += b;
    if (a < 0) {
        return a + mod;
    }
    if (a > 0) {
        return a % mod;
    }
}

int bin_pow(int a, int p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int k = bin_pow(a, p / 2);
        return mul(k, k);
    }
    return mul(bin_pow(a, p - 1), a);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    vector<int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        pref[i] = summ(pref[i - 1], c[i - 1]);
    }
    int inv = bin_pow(n, mod - 2);
    for (int k = 1; k <= n; k++) {
        int ans = 0;
        for (int i = 0, j = 0; i < n; i += k, j++) {
            ans = summ(ans, mul(j, summ(pref[min(n, i + k)], -pref[i])));
        }
        cout << mul(ans, inv) << " ";
    }
}
//


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int mod = 998244353;

int mul(int a, int b) {
    return (a * 1ll * b) % mod;
}

int summ(int a, int b) {
    return 1ll * (a + b) % mod;
}

int bin_pow(int a, int p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int k = bin_pow(a, p / 2);
        return mul(k, k);
    }
    return mul(bin_pow(a, p - 1), a);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    vector<int> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        pref[i] = summ(pref[i - 1], c[i - 1]);
    }
    int inv = bin_pow(n, mod - 2);
    for (int k = 1; k <= n; k++) {
        int ans = 0;
        for (int i = 0, j = 0; i < n; i += k, j++) {
            ans = summ(ans, mul(j, pref[min(n, i + k)] - pref[i]));
        }
        cout << mul(ans, inv) << " ";
    }
}


#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);

    vector<pair<int, int>> moment(n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &moment[i].first, &moment[i].second);

    int watching=0,index=0;
    for(int current=1;current<moment[n-1].second ; ){
        int start=moment[index].first, end=moment[index].second;
        if( current + k <= start ){
            current+=k;
            continue;
        }
        else{
            watching+=(end-current);
            current=end;
            index+=1;
        }
    }
    printf("%d\n", watching+1);
    return 0;
}


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

int main(){
	int n, k;
	scanf("%d%d", &n, &k);

	vector<pair<int, int>> moment(n);
	for(int i=0; i<n; i++)
		scanf("%d%d", &moment[i].first, &moment[i].second);

	int watching=0,index=0;
	for(int current=1;current<moment[n-1].second ; ){
		int start=moment[index].first, end=moment[index].second;
		if( current + k <= start ){
			current+=k;
			continue;
		}
		else{
			watching+=(end-current);
			current=end;
			index+=1;
		}
	}
	printf("%d\n", watching+1);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);

    vector<pair<int, int>> moment(n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &moment[i].first, &moment[i].second);

    int watching=0,index=0;
    for(int current=1;current<=moment[n-1].second ; ){
        if(index==n) break;
        int start=moment[index].first, end=moment[index].second;
        if( current + k <= start ){
            current+=k;
            continue;
        }
        else{
            watching+=(end-current+1);
            current=end+1;
            index+=1;
        }
    }
    printf("%d\n", watching);
    return 0;
}


#include <memory.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
#include <utility>
#include <map>

using namespace std;

void inputArray(int A[], int Alength)
{
    for (int i = 0; i < Alength; ++i)
    {
        scanf("%d", &A[i]);
    }
}

int main()
{
    int n,x,l,r;
    cin>>n>>x;
    int c=0;
    for (int i=0; i<n; i++)
    {
        cin>>l>>r;
        c+=(l-c-1)%x;
        c+=r-l+1;
    }
    cout<<c<<endl;
    return 0;
}


#include <memory.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
#include <utility>
#include <map>

using namespace std;

int n, x;
int mins;

void inputArray(int A[], int Alength)
{
    for (int i = 0; i < Alength; ++i)
    {
        scanf("%d", &A[i]);
    }
}

int main()
{
    int curMin = 1;
    cin >> n >> x;

    for (int i = 0; i < n; ++i)
    {
        int l, r;
        cin >> l >> r;

        if ((l - curMin) % x != 0)
        {
            mins += (l - curMin) % x;
        }

        mins += r - l;
        curMin = r;
    }

    cout << mins + 1 << endl;
    return 0;
}


#include <bits/stdc++.h>
#include <unordered_map>
#define all(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef map<int,int> mii;
typedef map<LL,LL> mLL;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vLL;
typedef vector<vLL> vvLL;
int main(){
      LL i,n,x,t=1,ans=0;
      cin>>n>>x;
      vLL L(n),R(n);
      for(i=0;i<n;i++){
            cin>>L[i]>>R[i];
      }
      for(i=0;i<n;i++){
            while(t+x<=L[i]){
                  t+=x;
            }
            ans+= R[i]-t+1;
            t=R[i]+1;
      }
      cout<<ans;
      return 0;
}


#include <bits/stdc++.h>
#include <unordered_map>
#define all(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef map<int,int> mii;
typedef map<LL,LL> mLL;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vLL;
typedef vector<vLL> vvLL;
int main(){
      LL i,n,x,t=1,ans=0;
      cin>>n>>x;
      vLL L(n),R(n);
      for(i=0;i<n;i++){
            cin>>L[i]>>R[i];
      }
      for(i=0;i<n;i++){
            if(t+x<=L[i]){
                  t+=x;
                  i--;
                  continue;
            }
            ans+= R[i]-t+1;
      }
      cout<<ans;
      return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include<string>
#include <unordered_map>

#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<int> vi;

int main() {
    int n,x;cin>>n>>x;
    int res = 0;
    int curr = 1;
    for (int i=0; i<n; ++i){
        int l,r;
        cin >>l >> r;
        while (curr + x <= l){
            curr += x;
        }
        res += (r-curr+1);
    }
    cout << res<<endl;
    return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include<string>
#include <unordered_map>

#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<int> vi;

int main() {
    int n,x;cin>>n>>x;
    int res = 0;
    int curr = 1;
    for (int i=0; i<n; ++i){
        int l,r;
        cin >>l >> r;
        while (curr + x <= l){
            curr += x;
        }
        //cout<< "Look on :" << curr << " - " << r<<endl;
        res += (r-curr+1);
        curr = r+1;
    }
    cout << res<<endl;
    return 0;
}


#include <algorithm>
#include <istream>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

void solve(std::istream& in, std::ostream& out)
{
	int n, x;
	in >> n >> x;
	int res = 0;
	int t = 1;
	while (n-- > 0) {
		int l, r;
		in >> l >> r;
		while (t + x <= l)
			t += x;
		res += r - t + 1;
		t = r + 1;
	}
	out << res << endl;
}

#include <iostream>

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    solve(std::cin, std::cout);
    return 0;
}


#include <algorithm>
#include <istream>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

void solve(std::istream& in, std::ostream& out)
{
	int n, x;
	in >> n >> x;
	int res = 1;
	int t = 1;
	while (n-- > 0) {
		int l, r;
		in >> l >> r;
		while (t + x <= l)
			t += x;
		res += r - t;
		t = r;
	}
	out << res << endl;
}

#include <iostream>

int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    solve(std::cin, std::cout);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define foo(i,n) for(int i = 0; i < (n); i++)
#define fii(i,m,n) for(int i = (m); i < (n); i++)
#define frr(i,m,n) for(int i = (m); i >= (n); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vii;

int main()
{
    int n,x;
    int minl = numeric_limits<int>::max();
    int maxl = numeric_limits<int>::min();
    cin>>n>>x;
    map<int,int> movi;
    foo(i,n)
    {
        int l,r;
        cin>>l>>r;
        if(l<minl)
            minl=l;
        if(r>maxl)
            maxl = r;
        movi[l] = r;
    }

    int prev = 0;

    int ans = 0;
    for(auto &e : movi)
    {
        ans+= ((e.second - e.first));
        if(!prev)
        {
            prev = e.second;
        }
        else
        {
            if(((e.first - prev))>=x)
                ans+= (((e.first - prev))%x);
            prev = e.second;
        }
    }

    if(minl - 1 >= x)
        ans+=((minl-1)%x);
    if(maxl > minl){ans+=1;}
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define foo(i,n) for(int i = 0; i < (n); i++)
#define fii(i,m,n) for(int i = (m); i < (n); i++)
#define frr(i,m,n) for(int i = (m); i >= (n); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vii;

int main()
{
    int n,x;
    cin>>n>>x;
    int ans{};
    int ss = 1;
    int s,e;
    foo(i,n)
    {
        cin>>s>>e;
        while(ss+x<=s)ss+=x;
        while(ss<=e){ans++;ss++;}
    }
    cout<<ans;
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define foo(i,n) for(int i = 0; i < (n); i++)
#define fii(i,m,n) for(int i = (m); i < (n); i++)
#define frr(i,m,n) for(int i = (m); i >= (n); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vii;

int main()
{
    int n,x;
    int minl = numeric_limits<int>::max();
    int maxl = numeric_limits<int>::min();
    cin>>n>>x;
    map<int,int> movi;
    foo(i,n)
    {
        int l,r;
        cin>>l>>r;
        if(l<minl)
            minl=l;
        if(r>maxl)
            maxl = r;
        movi[l] = r;
    }

    int prev = 0;

    int ans = 0;
    for(auto &e : movi)
    {
        ans+= ((e.second - e.first));
        if(!prev)
        {
            prev = e.second;
        }
        else
        {
            if(((e.first - prev))>=x)
                ans+= (((e.first - prev))%x);
            if(e.first < prev)
            {
                ans-=(prev-e.first);
            }
            prev = e.second;
        }
    }

    if(minl - 1 >= x)
        ans+=((minl-1)%x);
    if(maxl > minl){ans+=1;}
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define foo(i,n) for(int i = 0; i < (n); i++)
#define fii(i,m,n) for(int i = (m); i < (n); i++)
#define frr(i,m,n) for(int i = (m); i >= (n); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vii;

int main()
{
    int n,x;
    int minl = numeric_limits<int>::max();
    int maxl = numeric_limits<int>::min();
    cin>>n>>x;
    map<int,int> movi;
    foo(i,n)
    {
        int l,r;
        cin>>l>>r;
        if(l<minl)
            minl=l;
        if(r>maxl)
            maxl = r;
        movi[l] = r;
    }

    int prev = 0;

    int ans = 0;
    for(auto &e : movi)
    {
        ans+= ((e.second - e.first));
        if(!prev)
        {
            prev = e.second;
        }
        else
        {
            if(((e.first - prev))>0)
                ans+= (((e.first - prev))%x);
            if(e.first < prev)
            {
                ans-=(prev-e.first);
            }
            prev = e.second;
        }
    }

    if(minl - 1 > 0)
        ans+=((minl-1)%x);
    if(maxl > minl){ans+=1;}
    cout<<ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < pair <int, int> > a;

int main()
{
    int n, x;
    cin >> n >> x;
    for(int i = 0; i < n; i ++){
        int l, r;
        cin >> l >> r;
        a.push_back(make_pair(l, r));
    }
    sort(a.begin(), a.end());
    int j = 1, best = 0;
    for(int i = 0; i < n; i ++){
        if(j < a[i].first)
            best += (a[i].first - j) % x;
        if(j < a[i].second)
            best += a[i].second - a[i].first + 1,
            j = a[i].second + 1;
    }
    cout << best;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector < pair <int, int> > a;

int main()
{
    int n, x;
    cin >> n >> x;
    for(int i = 0; i < n; i ++){
        int l, r;
        cin >> l >> r;
        a.push_back(make_pair(l, r));
    }
    sort(a.begin(), a.end());
    int j = 1, best = 0;
    for(int i = 0; i < n; i ++){
            best += (a[i].first - j) % x;
            best += a[i].second - a[i].first + 1;
            j = a[i].second + 1;
    }
    cout << best;
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    int n,x; cin >> n >> x;
    int b,e;
    vector<bool> in(1e5+5,false);
    for (int i=0;i<n;++i) {cin >> b >> e; for (;b<=e;++b) in[b]=true;}
    int curr = 1, ct = 0;
    while (in[curr] && curr<=1e5) {++curr; ++ct;}
    for (;curr<=1e5;) {

        if (in[curr]) {++ct; ++curr;}
        else {for (int i=curr+1,_i=curr+x;i<min((int)1e5,_i);++i) if (in[i]) {ct+=i-curr+1; curr=i+1; break;} else if (i==min(_i,(int)1e5)-1) curr+=x;}
        if (curr>=1e5) break;
    }
    cout << ct << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    int n,x; cin >> n >> x;
    int b,e;
    vector<bool> in(1e5+5,false);
    for (int i=0;i<n;++i) {cin >> b >> e; for (;b<=e;++b) in[b]=true;}
    int curr = 1, ct = 0;
    while (in[curr] && curr<=1e5) {++curr; ++ct;}
    for (;curr<=1e5;) {
        if (in[curr]) {++ct; ++curr;}
        else if (x==1) {++curr;}
        else {for (int i=curr+1,_i=curr+x;i<min((int)1e5+1,_i);++i) if (in[i]) {ct+=i-curr+1; curr=i+1; break;} else if (i==min(_i,(int)1e5+1)-1) curr+=x;}
        if (curr>=1e5) break;
    }
    cout << ct << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    int n,x; cin >> n >> x;
    int b,e=1;
    int ct = 0;
    for (int i=0;i<n;++i) {
        cin >> b;
        ct+=(b-e)%x;
        cin >> e;
        ct+=(e-b+1);
    }
    cout << ct << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    int n,x; cin >> n >> x;
    int b,e;
    vector<bool> in(1e5+5,false);
    for (int i=0;i<n;++i) {cin >> b >> e; for (;b<=e;++b) in[b]=true;}
    int curr = 1, ct = 0;
    while (in[curr] && curr<=1e5) {++curr; ++ct;}
    for (;curr<=1e5;) {
        if (in[curr]) {++ct; ++curr;}
        else if (x==1) {++curr;}
        else {for (int i=curr+1,_i=curr+x;i<min((int)1e5,_i);++i) if (in[i]) {ct+=i-curr+1; curr=i+1; break;} else if (i==min(_i,(int)1e5)-1) curr+=x;}
        if (curr>=1e5) break;
    }
    cout << ct << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    int n,x; cin >> n >> x;
    int b,e=1;
    int ct = 0;
    for (int i=0;i<n;++i) {
        cin >> b;
        ct+=(b-e)%x;
        cin >> e;
        ct+=(e-b+1); ++e;
    }
    cout << ct << endl;
}


#include <iostream>

using namespace std;

int main()
{
    int n,x,Period_Start,Period_End;
    int Current_Minute = 1,Diff,Diff_Modulus_Skip;
    long long result = 0;

    cin >> n >> x;

    while(n!=0)
    {
        n--;

        cin >> Period_Start >> Period_End;

        Diff = Period_Start - Current_Minute;
        Diff_Modulus_Skip = Diff % x;

        result += (Period_End - Period_Start + 1) + Diff_Modulus_Skip;

    }

    cout << result;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n,x,Period_Start,Period_End;
    int Current_Minute = 0,Diff,Diff_Modulus_Skip;
    long long result = 0;

    cin >> n >> x;

    while(n!=0)
    {
        n--;

        cin >> Period_Start >> Period_End;

        Diff = Period_Start - Current_Minute - 1;
        Diff_Modulus_Skip = Diff % x;

        result += (Period_End - Period_Start + 1) + Diff_Modulus_Skip;

        Current_Minute = Period_End;

    }

    cout << result;

    return 0;
}


#include <bits/stdc++.h>

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const int MAXN = 100005;

int N, X;
int A[MAXN], B[MAXN];

int main(void) {
    cin >> N >> X;

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int pos = 1;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int l = 0, h = 100000, m;
        int best_pos = -1;

        for ( ; l <= h; ) {
            m = (l + h) / 2;

            Int next_pos = pos + X * (Int) m;

            if (next_pos <= A[i]) {
                best_pos = next_pos;
                l = m + 1;
            } else {
                h = m - 1;
            }
        }
        ans += B[i] - best_pos + 1;
        pos = B[i] + 1;
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const int MAXN = 100005;

int N, X;
int A[MAXN], B[MAXN];

int main(void) {
    cin >> N >> X;

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int pos = 1;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int l = 0, h = 100000, m;

        for ( ; l <= h; ) {
            m = (l + h) / 2;

            int next_pos = pos + X * m;

            if (next_pos <= A[i]) {
                pos = next_pos;
                l = m + 1;
            } else {
                h = m - 1;
            }
        }
        ans += B[i] - pos + 1;
        pos = B[i] + 1;
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned uint;

const int MAXN = 100005;

int N, X;
int A[MAXN], B[MAXN];

int main(void) {
    cin >> N >> X;

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    int pos = 1;
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int l = 0, h = 100000, m;
        int best_pos = -1;

        for ( ; l <= h; ) {
            m = (l + h) / 2;

            int next_pos = pos + X * m;

            if (next_pos <= A[i]) {
                best_pos = next_pos;
                l = m + 1;
            } else {
                h = m - 1;
            }
        }
        ans += B[i] - best_pos + 1;
        pos = B[i] + 1;
    }

    cout << ans << "\n";

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define MAX(a,b) ((a<b) ? b : a )

pair<int,int>  pairs[100005];
bool marked[100005];

int dp[100005];

int main()
{

	int n ,x;

	cin >> n >> x;

	int max_ =0 ;

	int ans =0 ;

	for(int i = 0 ; i< n ; i++){

		cin >> pairs[i].first >> pairs[i].second;

		ans += (pairs[i].second-pairs[i].first) + 1;
		max_ = MAX(max_,pairs[i].second);
		for(int j=pairs[i].first ; j<= pairs[i].second; j++)
			marked[j] = true;

		}

	dp[1] = marked[1] == false;

	for(int i =1; i<=max_ ; i++)
		if( marked[i] == false)
			dp[i] = dp[i-1] + 1;
		else
			dp[i] =  0;
/*

	for(int i  =1 ; i <=max_; i++)
		cout << dp[i] << " ";
	cout << endl;

*/

	for(int i = 0; i < n; i++)
		if( pairs[i].first != 1 )
		{
			int temp = dp[pairs[i].first-1];
//			cout << ( temp/x) << " "<< temp%x << endl;
			ans += ( temp/x!=temp/x + temp%x);
		}

	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{

	int n ,x,a,b,ans=0;

	cin >> n >> x;

	int pos = 1;

	for(int i = 0 ; i< n ; i++)
	{

		cin >> a >> b;

		ans += ( b - a + 1 );
		ans += ( a- pos)%x;
		pos = b + 1;
	}

	cout << ans;

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
    int n, x, a, b;
    int st = 1, res = 0;
    cin >> n >> x;
    For(i, 0, n)
    {
        cin >> a >> b;
        while (true)
        {
            if (st + 3 <= a)
                st += 3;
            else
            {
                st++;
                res++;
            }
            if (st >= b)
                break;

        }
    }
    cout << res+1 << endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
	int n, x, a, b;
	int st = 0, res = 0;
	cin >> n >> x;
	For(i, 0, n)
	{
		cin >> a >> b;
		while (true)
		{
			if (st + 3 <= a)
				st += 3;
			else
			{
				st++;
				res++;
			}
			if (st >= b)
				break;

		}
	}
	cout << res << endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
    int n, x, a, b;
    int st = 1, res = 0;
    cin >> n >> x;
    For(i, 0, n)
    {
        cin >> a >> b;
        while (true)
        {
            if (st + x <= a)
                st += x;
            else
            {
                st++;
                res++;
            }
            if (st >= b)
                break;
        }
    }
    cout << res+1 << endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
	int n, x, a, b;
	int st = 1, res = 0;
	cin >> n >> x;
	For(i, 0, n)
	{
		cin >> a >> b;
		while (true)
		{
			if (st + x <= a)
				st += x;
			else
			{
				st++;
				res++;
			}
			if (st > b)
				break;
		}
	}
	cout << res+1 << endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
    int n, x, a, b;
    int st = 1, res = 0;
    cin >> n >> x;
    For(i, 0, n)
    {
        cin >> a >> b;
        while (true)
        {
            if (st + x <= a)
                st += x;
            else
            {
                st++;
                res++;
            }
            if (st > b)
                break;
        }
    }
    cout << res<< endl;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }
int main()
{
    int n, x, a, b;
    int st = 0, res = 0;
    cin >> n >> x;
    For(i, 0, n)
    {
        cin >> a >> b;
        while (true)
        {
            if (st + x <= a)
                st += x;
            else
            {
                st++;
                res++;
            }
            if (st >= b)
                break;

        }
    }
    cout << res << endl;
}


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int number,value,borne1,borne2,actual=1,temps=0;

    cin >> number >> value;

    for (int i=0; i<number; i++)
    {
        cin >> borne1 >> borne2;
        if (actual>borne2)
            borne2--;
        while (actual<borne2)
        {
            while (actual<=borne1)
                actual+=value;

            if (actual==borne1)
                temps=temps+(borne2-borne1)+1;
            else if (actual>borne1)
            {
                actual-=value;
                temps=temps+(borne2-borne1)+1+(borne1-actual);
            }
            actual=borne2+1;
        }
    }
    cout << temps << endl;

    return 0;
}


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int number,value,borne1,borne2,actual=1,temps=0;

    cin >> number >> value;

    for (int i=0; i<number; i++)
    {
        cin >> borne1 >> borne2;
        if (actual>borne2)
            borne2--;

        //while (actual<borne2)
        //{
            while (actual<=borne1)
                actual+=value;

            if (actual==borne1)
                temps=temps+(borne2-borne1)+1;
            else if (actual>borne1)
            {
                actual-=value;
                temps=temps+(borne2-borne1)+1+(borne1-actual);
            }
            actual=borne2+1;
        //}
    }
    cout << temps << endl;

    return 0;
}


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int number,value,borne1,borne2,actual=1,temps=0;

    cin >> number >> value;

    for (int i=0; i<number; i++)
    {
        cin >> borne1 >> borne2;
        actual=1;

        while (actual<=borne1)
                actual+=value;

            if (actual==borne1)
                temps=temps+(borne2-borne1)+1;
            else if (actual>borne1)
            {
                actual-=value;
                temps=temps+(borne2-borne1)+1+(borne1-actual);
            }

    }
    cout << temps << endl;

    return 0;
}


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int number,value,borne1,borne2,actual=1,temps=0;

    cin >> number >> value;

//2 3
//5 6
//10 12
    for (int i=0; i<number; i++)
    {
        cin >> borne1 >> borne2;
        while (actual<borne2)
        {
            while (actual<=borne1)
            {
                actual+=value;
   //             cout << "actual " << actual << endl;
            }

            if (actual==borne1)
                temps=temps+(borne2-borne1)+1;
            else if (actual>borne1)
            {
                actual-=value;
                temps=temps+(borne2-borne1)+1+(borne1-actual);
            }

 //           cout << "temps " << temps << endl;
            actual=borne2+1;

        }

    }
    cout << temps << endl;

    return 0;
}


#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int number,value,borne1,borne2,actual=1,temps=0;

    cin >> number >> value;

//2 3
//5 6
//10 12
    for (int i=0; i<number; i++)
    {
        cin >> borne1 >> borne2;
        while (actual<borne2)
        {
            while (actual<=borne1)
            {
                actual+=value;
   //             cout << "actual " << actual << endl;
            }

            if (actual==borne1)
                temps=temps+(borne2-borne1)+1;
            else if (actual>borne1)
            {
                actual-=value;
                temps=temps+(borne2-borne1)+1+(borne1-actual);
            }

 //           cout << "temps " << temps << endl;
            actual=borne2+1;

        }

        cout << temps << endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

template<typename T> std::ostream& operator<<(std::ostream& str, const std::vector<T>& v) { str << "["; for(auto n : v) str << n << ", "; str << "]"; return str; }

#define debug(x) cout <<  #x  << ": " << x << endl

int main() {
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);

	int n,x;
	cin >> n >> x;

	int cur=1;
	int minutes = 0;
	for(int i=0; i<n; ++i) {
		int li, ri;
		cin >> li >> ri;

		while(cur+x <= li) cur += x;
		minutes += (ri-cur+1);
		cur = ri+1;
	}

	cout << minutes << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

template<typename T> std::ostream& operator<<(std::ostream& str, const std::vector<T>& v) { str << "["; for(auto n : v) str << n << ", "; str << "]"; return str; }

#define debug(x) cout <<  #x  << ": " << x << endl

int main() {
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);

	int n,x;
	cin >> n >> x;

	int cur=1;
	int minutes = 0;
	for(int i=0; i<n; ++i) {
		int li, ri;
		cin >> li >> ri;

		while(cur+x <= li) cur += x;
		minutes += (ri-cur+1);
		cur = ri;
	}

	cout << minutes << endl;
}


//Author:Sourabh
#include<bits/stdc++.h>
using namespace std;
//Start template__sunny_red_devil
typedef long long ll;
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define SIZE(X) ((int)(X.size()))
#define LENGTH(X) ((int)(X.length()))
#define MP(X,Y) make_pair(X,Y)
typedef long long LL;
typedef long long int int64;
typedef unsigned long long uLL;
#define FOR(i,n) for(int i=0;i<n;i++)
#define FU(i,a,n) for(int i=a;i<=n;i++)
#define FD(i,a,n) for(int i=n;i>=a;i--)
#define GI(n) scanf("%d",&n)
#define GS(n) scanf("%s"&s)
#define GII(n,m) scanf("%d %d",&n,&m)
#define PI(n) printf("%d\n",n)
#define PII(n,m) printf("%d %d\n",n,m)
vector < pii > v;

int main(){
    ios::sync_with_stdio(false);
    int n;
    ll x;
    cin>>n>>x;
    FOR(i,n){
        int l,r;
        cin>>l>>r;
        v.push_back(MP(l,r));
    }
    int cur  = 1,min = 0,counter =0,i=0;
    while(counter < n){
        //cout<<v[i].first<<v[i].second<<endl;
        int diff = v[i].first - cur;
        //cout<<diff<<cur<<min<<endl;
        if(diff >= x){
            cur += x;
            continue;
        }else if(diff < x){
            min += (v[i].second-cur + 1);
            cur = cur + min;
            i++;counter++;
        }

    }
    cout<<min<<endl;
    return 0;
}


//Author:Sourabh
#include<bits/stdc++.h>
using namespace std;
//Start template__sunny_red_devil
typedef long long ll;
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define SIZE(X) ((int)(X.size()))
#define LENGTH(X) ((int)(X.length()))
#define MP(X,Y) make_pair(X,Y)
typedef long long LL;
typedef long long int int64;
typedef unsigned long long uLL;
#define FOR(i,n) for(int i=0;i<n;i++)
#define FU(i,a,n) for(int i=a;i<=n;i++)
#define FD(i,a,n) for(int i=n;i>=a;i--)
#define GI(n) scanf("%d",&n)
#define GS(n) scanf("%s"&s)
#define GII(n,m) scanf("%d %d",&n,&m)
#define PI(n) printf("%d\n",n)
#define PII(n,m) printf("%d %d\n",n,m)
vector < pii > v;

int main(){
    ios::sync_with_stdio(false);
    int n;
    ll x;
    cin>>n>>x;
    FOR(i,n){
        ll l,r;
        cin>>l>>r;
        v.push_back(MP(l,r));
    }
    int cur  = 1,min = 0,counter =0,i=0;
    while(counter < n){
        //cout<<v[i].first<<v[i].second<<endl;
        int diff = v[i].first - cur;
        //cout<<diff<<cur<<min<<endl;
        if(diff >= x){
            cur += x;
            continue;
        }else if(diff < x){
            min += (v[i].second-cur + 1);
            cur = cur + min;
            i++;counter++;
        }

    }
    cout<<min<<endl;
    return 0;
}


//Author:Sourabh
#include<bits/stdc++.h>
using namespace std;
//Start template__sunny_red_devil
typedef long long ll;
typedef vector <int> vi;
typedef pair< ll ,ll > pii;
#define SIZE(X) ((int)(X.size()))
#define LENGTH(X) ((int)(X.length()))
#define MP(X,Y) make_pair(X,Y)
typedef long long LL;
typedef long long int int64;
typedef unsigned long long uLL;
#define FOR(i,n) for(int i=0;i<n;i++)
#define FU(i,a,n) for(int i=a;i<=n;i++)
#define FD(i,a,n) for(int i=n;i>=a;i--)
#define GI(n) scanf("%d",&n)
#define GS(n) scanf("%s"&s)
#define GII(n,m) scanf("%d %d",&n,&m)
#define PI(n) printf("%d\n",n)
#define PII(n,m) printf("%d %d\n",n,m)
vector < pii > v;

int main(){
    ios::sync_with_stdio(false);
    int n;
    ll x;
    int cur=1,min=0;
    cin>>n>>x;
    FOR(i,n){
        ll l,r;
        cin>>l>>r;
        while(cur + x <= l){
            cur += x;
        }
        min += (r-cur+1);
        cur = r+1;
    }
    cout<<min<<endl;
    return 0;
}


#include<iostream>
#include<vector>

using namespace std;

void watch(){

    int n;
    long long int x,m,sum(0);

    cin>>n>>x;

    vector<long long int> movie;

    for(int i=0; i<n; ++i){

        cin>>m;
        movie.push_back(m);
    }

    for(unsigned int i = 0; i<movie.size()-1; ++i){

        sum+=movie[i+1]-movie[i];
    }

    for(unsigned int i = 0; i<movie.size(); ++i){

        if(i==0){

            sum+=(movie[i]-1)%x;
        }
        else{

            sum+=(movie[i]-movie[i-1])%x;
        }

        ++i;//you need to skip every other element
    }

    cout<<sum;

}

int main(){

    watch();

    return 0;
}


#include<iostream>
#include<vector>

using namespace std;

void watch(){

    int n;
    long long int x,m,sum(0);

    cin>>n>>x;

    vector<long long int> movie;

    for(int i=0; i<2*n; ++i){

        cin>>m;
        movie.push_back(m);
    }

    for(unsigned int i = 0; i<movie.size()-1; ++i){

        sum+=(movie[i+1]-movie[i]+1);
        ++i;
    }
//cout<<sum<<endl;
    for(unsigned int i = 0; i<movie.size(); ++i){
//cout<<i<<endl;
        if(i==0){

            sum+=((movie[i]-1)%x);
        }
        else{

            sum+=((movie[i]-movie[i-1]-1)%x);
        }

        ++i;//you need to skip every other element
    }

    cout<<sum;

}

int main(){

    watch();
    //cout<<(5-1)%3<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,x,l,r;
vector< pair<int,int> > v;

int main(void)
{
    cin >> n >> x;

    for (int i = 0; i < n; ++i)
    {
        cin >> l >> r;
        v.push_back(make_pair(l,r));
    }

    sort(v.begin(), v.end());

    int curr = 1;
    int where = 0;
    int total = 0;
    while (curr < 100011)
    {
        // printf("curr = %d where = %d\n",curr,where);
        if (where < v.size() && curr == v[where].first)
        {
            while (curr <= v[where].second)
            {
                total++;
                curr++;
            }

            where++;
        }
        else if (where >= v.size() || curr + x <= v[where].first)
        {
            curr += x;
        }
        else
        {
            curr++;
            total++;
        }
    }

    cout << total << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n,x,l,r;
vector< pair<int,int> > v;

int main(void)
{
    cin >> n >> x;

    for (int i = 0; i < n; ++i)
    {
        cin >> l >> r;
        v.push_back(make_pair(l,r));
    }

    sort(v.begin(), v.end());

    int curr = 1;
    int where = 0;
    int total = 0;
    while (curr < 100010)
    {
        if (where < v.size() && curr == v[where].first)
        {
            while (curr <= v[where].second)
            {
                total++;
                curr++;
            }

            where++;
        }
        if (where >= v.size() || curr + x <= v[where].first)
        {
            curr += x;
        }
        else
        {
            curr++;
            total++;
        }
    }

    cout << total << "\n";
    return 0;
}


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

int main() {

    int n , x ;
    while( cin >> n >> x ) {
        int a , b ;
        int tot = 0 ;
        while( n -- ) {
            cin >> a >> b ;
            int curr = 1 ;
            while( curr+x <= a )curr += x ;
            while( curr <= b )tot ++ , curr++ ;
        }
        cout << tot << endl ;
    }

    return 0;
}


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

int main() {

    int n , x ;
    while( cin >> n >> x ) {
        int a , b ;
        int tot = 0 ;
          int curr = 1 ;
        while( n -- ) {
            cin >> a >> b ;

            while( curr+x <= a )curr += x ;
            while( curr <= b )tot ++ , curr++ ;
        }
        cout << tot << endl ;
    }

    return 0;
}


#include<iostream>

using namespace std;

int main()
{
    int n, x, l, r;

    cin >> n >> x;

    int ans = 0, cur = 1;

    for(int i = 1; i <= n; i++)
    {
        cin >> l >> r;

        while(cur + x <= l)
        {
            cur += x;
        }

        ans += r - cur + 1;

        cur = r + 1;
    }

    cout << ans;
}


#include<iostream>

using namespace std;

int main()
{
    int n, x;

    int a[n + 1], b[n + 1];

    cin >> n >> x;

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

    int res = 0, tmp = 1;

    for(int i = 1; i <= n; i++)
    {
         while(tmp + x <= a[i]) tmp += x;

         res += b[i] - tmp + 1;

         tmp = b[i] + 1;
    }

    cout << res;
}


#include<iostream>

#include<cstring>

using namespace std;

int main()
{
    int n, x;

    cin >> n >> x;

    int a[n + 5], b[n + 5];

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

    int res = 0, tmp = 1;

    for(int i = 1; i <= n; i++)
    {
        while(tmp + x <= a[i]) tmp += x;

        res += b[i] - tmp + 1;

        tmp = b[i] + 1;

    }

    cout << res;
}


#include<iostream>

using namespace std;

int main()
{
    int n, x;

    int a[n + 1], b[n + 1];

    cin >> n >> x;

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

    int res = 0, tmp = 1;

    for(int i = 1; i <= n; i++)
    {
         while(tmp + x <= a[i]) tmp += x;

         res += b[i] - tmp + 1;

         if((a[i + 1] - b[i]) % x == 0) tmp = a[i + 1];
         else tmp = b[i] + 1;
    }

    cout << res;
}