Language: Java

import java.util.*;

public class Main {
  static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long[] kaijou = new long[n + 1];
    kaijou[0] = 1;
    for(int i = 1; i < n + 1; i++) {
      kaijou[i] = (kaijou[i - 1] * i) % MOD;
    }
    int[] suuretu = new int[n + 1];
    long[] aho = new long[n + 1];
    for(int i = 0; i < n + 1; i++) {
      long a = sc.nextLong();
      aho[i] = a;
      suuretu[a]++;
    }
    long u = 0;
    for(int i = 0; i < n + 1; i++) {
      if(suuretu[i] == 2) u = i;
    }
    int index = 0;
    int index2 = 0;
    boolean flg = true;
    for(int i = 0; i < n + 1; i++) {
      if(aho[i] == u) {
        if(flg) {
          flg = false;
          index = i;
        } else {
          index2 = i;
        }
      }
    }
    long unko = (long)(index + n - index2);
    long[] dp = new long[unko + 1];
    long[] dp2 = new long[n + 2];
    for(int k = 0; k < unko + 1; k++) {
      long inv = func(kaijou[k], MOD - 2);
      long inv2 = func(kaijou[unko - k], MOD - 2);
      long ret = (kaijou[unko] * inv) % MOD;
      ret = (ret * inv2) % MOD;
      dp[k] = ret;
    }
    for(int k = 0; k < n + 2; k++) {
      long inv = func(kaijou[k], MOD - 2);
      long inv2 = func(kaijou[n + 1 - k], MOD - 2);
      long ret = (kaijou[n + 1] * inv) % MOD;
      ret = (ret * inv2) % MOD;
      dp2[k] = ret;
    }
    for(int k = 1; k <= n + 1; k++) {
      long ans = dp2[k];
      if(k >= 1) {
        if(ans >= dp[k - 1]) {
          ans -= dp[k - 1];
        } else {
          ans = (ans + MOD - dp[k - 1]) % MOD;
        }
      }
      System.out.println(ans);
    }
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    long t = func(a, x / 2);
    long ret = (t * t) % MOD;
    if(x % 2 == 1) ret = (ret * a) % MOD;
    return ret;
  }
}

Compiler output:
Main.java:8: error: incompatible types: possible lossy conversion from long to int
    long[] kaijou = new long[n + 1];
                               ^
Main.java:13: error: incompatible types: possible lossy conversion from long to int
    int[] suuretu = new int[n + 1];
                              ^
Main.java:14: error: incompatible types: possible lossy conversion from long to int
    long[] aho = new long[n + 1];
                            ^
Main.java:18: error: incompatible types: possible lossy conversion from long to int
      suuretu[a]++;
              ^
Main.java:38: error: incompatible types: possible lossy conversion from long to int
    long[] dp = new long[unko + 1];
                              ^
Main.java:39: error: incompatible types: possible lossy conversion from long to int
    long[] dp2 = new long[n + 2];
                            ^
Main.java:42: error: incompatible types: possible lossy conversion from long to int
      long inv2 = func(kaijou[unko - k], MOD - 2);
                                   ^
Main.java:43: error: incompatible types: possible lossy conversion from long to int
      long ret = (kaijou[unko] * inv) % MOD;
                         ^
Main.java:49: error: incompatible types: possible lossy conversion from long to int
      long inv2 = func(kaijou[n + 1 - k], MOD - 2);
                                    ^
Main.java:50: error: incompatible types: possible lossy conversion from long to int
      long ret = (kaijou[n + 1] * inv) % MOD;
                           ^
10 errors