Problem:
Score : 600 points

Problem Statement

You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.
It is known that each of the n integers 1,...,n appears at least once in this sequence.

For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.

Notes

If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence.

A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. For example, the sequences 1,3,5 and 1,2,3 are subsequences of 1,2,3,4,5, while 3,1,2 and 1,10,100 are not.

Constraints

1 \leq n \leq 10^5

1 \leq a_i \leq n

Each of the integers 1,...,n appears in the sequence.

n and a_i are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_{n+1}

Output

Print n+1 lines.
The k-th line should contain the number of the different subsequences of the given sequence with length k, modulo 10^9+7.

Sample Input 1

3
1 2 1 3

Sample Output 1

3
5
4
1

There are three subsequences with length 1: 1 and 2 and 3.

There are five subsequences with length 2: 1,1 and 1,2 and 1,3 and 2,1 and 2,3.

There are four subsequences with length 3: 1,1,3 and 1,2,1 and 1,2,3 and 2,1,3.

There is one subsequence with length 4: 1,2,1,3.

Sample Input 2

1
1 1

Sample Output 2

1
1

There is one subsequence with length 1: 1.

There is one subsequence with length 2: 1,1.

Sample Input 3

32
29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9

Sample Output 3

32
525
5453
40919
237336
1107568
4272048
13884156
38567100
92561040
193536720
354817320
573166440
818809200
37158313
166803103
166803103
37158313
818809200
573166440
354817320
193536720
92561040
38567100
13884156
4272048
1107568
237336
40920
5456
528
33
1

Be sure to print the numbers modulo 10^9+7.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

long long P = 1000000007;

long long gcd(long long a, long long b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}

// return (x, y) (a * x + b * y = gcd(a, b))
pair<long long, long long> exeuclid(long long a, long long b) {
  if (b == 0)
    return make_pair(1, 0);
  pair<long long, long long> ret = exeuclid(b, a % b);
  ret.first -= a / b * ret.second;
  return make_pair(ret.second, ret.first);
}

// v := [(modulo, reminder)]
// moduloes should be coprime
long long CRT(vector<pair<ll, ll>> v) {
  long long mod = 1;
  long long ret = 0;
  for (int i = 0; i < v.size(); i++) {
    pair<ll, ll> xy = exeuclid(mod, v[i].first);
    long long M = mod * v[i].first;
    long long l = ((v[i].second * mod) % M) * xy.first;
    l %= M;
    long long r = ((ret * v[i].first) % M) * xy.second;
    r %= M;
    ret = (l + r) % M;
    ret += M;
    ret %= M;
    mod = M;
  }
  return ret;
}

ll mod_pow(ll e, ll x, ll p) {
  ll r = 1;
  e %= p;
  while (x) {
    if (x & 1) {
      r *= e;
      r %= p;
    }
    e *= e;
    e %= p;
    x >>= 1;
  }
  return r;
}

template<class T>
T extgcd(T a, T b, T &x, T &y) {
  for (T u = y = 1, v = x = 0; a;) {
    T q = b / a;
    swap(x -= q * u, u);
    swap(y -= q * v, v);
    swap(b -= q * a, a);
  }
  return b;
}

ll mod_inv(ll a, ll b) {
  return (exeuclid(a, b).first % b + b) % b;
}

template<int mod, int primitive_root>
class NTT {
public:
  int get_mod() const { return mod; }

  void _ntt(vector<ll> &a, int sign) {
    const int n = a.size();
    assert((n ^ (n & -n)) == 0); //n = 2^k

    const int g = 3; //g is primitive root of mod
    int h = (int) mod_pow(g, (mod - 1) / n, mod); // h^n = 1
    if (sign == -1) h = (int) mod_inv(h, mod); //h = h^-1 % mod

    //bit reverse
    int i = 0;
    for (int j = 1; j < n - 1; ++j) {
      for (int k = n >> 1; k > (i ^= k); k >>= 1);
      if (j < i) swap(a[i], a[j]);
    }

    for (int m = 1; m < n; m *= 2) {
      const int m2 = 2 * m;
      const ll base = mod_pow(h, n / m2, mod);
      ll w = 1;
      for (int x = 0; x < m; x++) {
        for (int s = x; s < n; s += m2) {
          ll u = a[s];
          ll d = a[s + m] * w % mod;
          a[s] = u + d;
          if (a[s] >= mod) a[s] -= mod;
          a[s + m] = u - d;
          if (a[s + m] < 0) a[s + m] += mod;
        }
        w = w * base % mod;
      }
    }

    for (auto &x : a) if (x < 0) x += mod;
  }

  void ntt(vector<ll> &input) {
    _ntt(input, 1);
  }

  void intt(vector<ll> &input) {
    _ntt(input, -1);
    const int n_inv = mod_inv(input.size(), mod);
    for (auto &x : input) x = x * n_inv % mod;
  }

  // 畳み込み演算を行う
  vector<ll> convolution(const vector<ll> &a, const vector<ll> &b) {
    int ntt_size = 1;
    while (ntt_size < a.size() + b.size()) ntt_size *= 2;

    vector<ll> _a = a, _b = b;
    _a.resize(ntt_size);
    _b.resize(ntt_size);

    ntt(_a);
    ntt(_b);

    for (int i = 0; i < ntt_size; i++) {
      (_a[i] *= _b[i]) %= mod;
    }

    intt(_a);
    return _a;
  }
};

ll garner(vector<pair<ll, ll>> mr, int mod) {
  mr.emplace_back(mod, 0);

  vector<ll> coffs(mr.size(), 1);
  vector<ll> constants(mr.size(), 0);
  for (int i = 0; i < mr.size() - 1; i++) {
    // coffs[i] * v + constants[i] == mr[i].second (mod mr[i].first) を解く
    ll v = (mr[i].second - constants[i]) * mod_inv(coffs[i], mr[i].first) % mr[i].first;
    if (v < 0) v += mr[i].first;

    for (int j = i + 1; j < mr.size(); j++) {
      (constants[j] += coffs[j] * v) %= mr[j].first;
      (coffs[j] *= mr[i].first) %= mr[j].first;
    }
  }

  return constants[mr.size() - 1];
}

typedef NTT<167772161, 3> NTT_1;
typedef NTT<469762049, 3> NTT_2;
typedef NTT<1224736769, 3> NTT_3;
NTT_1 ntt1;
NTT_2 ntt2;
NTT_2 ntt3;
// ref: https://math314.hateblo.jp/entry/2015/05/07/014908

// NTT
// c[i] = for j,k a[j] + b[k] if j + k == i mod P
vector<ll> mod_conv(vector<ll> a, vector<ll> b, ll P) {
  for (auto &i : a) i %= P;
  for (auto &i : b) i %= P;
  auto v1 = ntt1.convolution(a, b);
  auto v2 = ntt2.convolution(a, b);
  auto v3 = ntt3.convolution(a, b);
  int n = v2.size();
  vector<ll> ret(n);
  for (int i = 0; i < n; i++) {
    ret[i] = garner(vector<pair<ll, ll>>(
        {
            make_pair(ntt1.get_mod(), v1[i]),
            make_pair(ntt2.get_mod(), v2[i]),
            make_pair(ntt3.get_mod(), v3[i])
        }), P);
  }
  return ret;
}

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmb(201010);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  n++;
  vector<int> a(n);
  vector<int> c(n);
  int l, r, now;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
    c[a[i]]++;
    if (c[a[i]] == 2) now = a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == now) {
      l = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == now) {
      r = i;
      break;
    }
  }
  ll l1 = l, l2 = r - l - 1, l3 = n - r - 1;

  vector<ll> orig(n + 1);
  for (int i = 0; i <= l2; i++) {
    orig[i] += cmb.comb(l2, i);
    orig[i] %= P;
    if (i == 0) {
      orig[1] += 1;
      orig[1] %= P;
    } else {
      orig[i + 1] += (2 * cmb.comb(l2, i)) % P;
      orig[i + 1] %= P;
    }
    orig[i + 2] += cmb.comb(l2, i);
    orig[i + 2] %= P;
  }
  vector<ll> b(n + 1);
  for (int i = 0; i <= l1 + l3; i++) {
    b[i] = cmb.comb(l1 + l3, i);
  }

  vector<ll> ans = mod_conv(orig, b, P);

  for (int i = 1; i <= n; i++) cout << ans[i] << endl;

  return 0;
}