#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

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(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt;

// - 多項式補間：n次以下の多項式fを具体的に求めるのが難しいときに用いるテク

// N次以下の多項式fについて、
// 相異なるn+1個の点(x_i, y_i)がfを通る(f(x_i)=y_iを満たす)とき、
// f(T)の値を返す
// O(N^2)
mint LagrangeInterPolation(vector<mint> x, vector<mint> y, mint T) {
    int N = x.size();
    N--;
    mint res = 0;
    for(int i = 0; i <= N; i++) {
        mint t = 1;
        for(int j = 0; j <= N; j++) {
            if(i == j) {
                continue;
            }
            t *= T - x[j];
            t /= (x[i] - x[j]);
        }
        res += t * y[i];
    }
    return res;
}

// N次以下の多項式fについて、
// 相異なるn+1個の点(x_i, y_i)がfを通る(f(x_i)=y_iを満たす)とき、
// f(x)を返す(f(x)の係数を返す)
// O(N^2)
vector<mint> LagrangeInterPolationCoef(vector<mint> x, vector<mint> y) {
    int N = x.size();
    N--;
    for(int i = 0; i <= N; i++) {
        mint t = 1;
        for(int j = 0; j <= N; j++) {
            if(i == j) {
                continue;
            }
            t *= (x[i] - x[j]);
        }
        y[i] /= t;
    }
    int now = 0;
    int next = 1;
    vector<vector<mint>> dp(2, vector<mint>(N + 2));
    dp[0][0] = -x[0];
    dp[0][1] = 1;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= N + 1; j++) {
            dp[next][j] = dp[now][j] * (-x[i]);
            if(j >= 1) {
                dp[next][j] += dp[now][j - 1];
            }
        }
        swap(next, now);
    }
    vector<mint> xinv(N + 1);
    for(int i = 0; i <= N; i++) {
        xinv[i] = x[i].inverse();
    }
    vector<mint> res(N + 1); // f(x)
    for(int i = 0; i <= N; i++) {
        if(y[i] == 0) {
            continue;
        }
        // 0で割らないように場合分け
        if(x[i] == 0) {
            for(int j = 0; j <= N; j++) {
                res[j] += dp[now][j + 1] * y[i];
            }
        } else {
            res[0] -= dp[now][0] * xinv[i] * y[i];
            mint prev = -dp[now][0] * xinv[i];
            for(int j = 1; j <= N; j++) {
                res[j] -= (dp[now][j] - prev) * xinv[i] * y[i];
                prev = (-dp[now][j] + prev) * xinv[i];
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p;
    cin >> p;
    mod = p;
    vector<mint> a(p);
    vector<mint> x(p), y(p);
    for(int i = 0; i < p; i++) {
        cin >> a[i];
        x[i] = i;
        y[i] = a[i];
    }
    auto ans = LagrangeInterPolationCoef(x, y);
    for(auto i : ans) {
        cout << i << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 384