#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct ModInt {
    using u64 = std::uint_fast64_t;

    public:
    u64 a;

    ModInt(long long x = 0) : a(x >= 0 ? x%Modulus() : (Modulus() - (-x)%Modulus()) % Modulus()) {}

    static u64 &Modulus() {static u64 Modulus = 0; return Modulus;}
    static void set (u64 M) {Modulus() = M;}

    ModInt operator+(const ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(const ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(const ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(const ModInt rhs) const {return ModInt(*this) /= rhs;}
    ModInt operator^(const long long rhs) const {return ModInt(*this) ^= rhs;}
    ModInt &operator+=(const ModInt rhs) {
        a += rhs.a;
        if (a >= Modulus()) {
            a -= Modulus();
        }
        return *this;
    }
    ModInt &operator-=(const ModInt rhs) {
        if (a < rhs.a) {
            a += Modulus();
        }
        a -= rhs.a;
        return *this;
    }
    ModInt &operator*=(ModInt rhs) {
        a = a * rhs.a % Modulus();
        return *this;
    }
    ModInt &operator/=(ModInt rhs) {
        u64 exp = Modulus() - 2;
        while (exp) {
        if (exp % 2) {
            *this *= rhs;
        }
        rhs *= rhs;
        exp /= 2;
        }
        return *this;
    }

    ModInt &operator^=(long long exp) {
        ModInt b = a;
        a = 1;
        while (exp) {
            if (exp&1) *this *= b;
            exp >>= 1;
            b *= b;
        }
        return *this;
    }

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

using mint = ModInt;

vector<mint> lagrange_interpolation(const vector<mint> &x,vector<mint> y) {
    int N = x.size() - 1;

    for (int i = 0; i <= N; i++) {
        mint tmp = 1;
        for (int j = 0; j <= N; j++) {
            if (i != j) tmp *= x[i] - x[j];
        }
        y[i] /= tmp;
    }
    vector<vector<mint>> dp(N+2, vector<mint>(N+2));
    dp[0][0] = 1;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N+1; j++) {
            dp[i+1][j] -= dp[i][j]*x[i];
            if (j) dp[i+1][j] += dp[i][j-1];
        }
    }

    vector<mint> xinv(N+1,1);
    for (int i = 0; i <= N; i++) xinv[i] /= x[i];
    vector<mint> ret(N+1);
    for (int i = 0; i <= N; i++) {
        if (x[i]==0) {
            for (int j = 0; j <= N; j++) {
                ret[j] += dp[N+1][j+1]*y[i];
            }
        } else {
            mint cur = 0;
            for (int j = 0; j <= N; j++) {
                cur = mint(0) - (dp[N+1][j] - cur) * xinv[i];
                ret[j] += cur * y[i];
            }
        }
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int p; cin >> p;
    ModInt::set(p);
    vector<mint> A(p);
    rep(i,p) {
        int a; cin >> a;
        A[i] = a;
    }

    vector<mint> x(p);
    rep(i,p) x[i] = i;
    auto ans = lagrange_interpolation(x,A);

    for (auto i : ans) cout << i.a << " ";
    cout << ln;
}

Measured memory_bytes: 70784