Language: Java

import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt() + 1
    val A = map(N)(_ => sc.nextInt())
    val dbl = {
      val cnt = Array.ofDim[Int](N)
      rep(N)(i => cnt(A(i)) += 1)
      cnt.indexOf(2)
    }
    val L = A.indexOf(dbl)
    val R = N - A.lastIndexOf(dbl) - 1

    def powMod(x: Int, n: Int, m: Int): Int = {
      def step(x: Long, n: Int, stack: Long): Long = {
        n match {
          case 0 => stack
          case _ => step(x * x % m, n / 2, if (n % 2 == 1) stack * x % m else stack)
        }
      }
      step(x, n, 1).toInt
    }

    val F = Array.ofDim[Long](N + 1)
    F(0) = 1
    rep(N) { i =>
      F(i + 1) = F(i) * (i + 1) % MOD
    }
    val I = Array.ofDim[Long](F.length)
    I(N) = powMod(F(N).toInt, MOD - 2, MOD)

    // x! = x(x-1)!
    // x!I(x!) ≡ (x-1)!I((x-1)!)
    // I((x-1)!) ≡ I(x!) * x   MODがでかいので(x-1)!はMODと素
    rep_r(N) { i =>
      I(i) = I(i + 1) * (i + 1) % MOD
    }

    def comb(n: Int, k: Int): Long = {
      if (n < k) 0
      else F(n) * I(n - k) % MOD * I(k) % MOD
    }

    rep(N, 1) { k =>
      val ans = (MOD + comb(N, k) - comb(L + R, k - 1)) % MOD
      out.println(ans)
    }
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Compiler output:
Main.java:1: error: as of release 9, '_' is a keyword, and may not be used as an identifier
import java.io._
               ^
Main.java:1: error: ';' expected
import java.io._
                ^
Main.java:2: error: ';' expected
import java.util.StringTokenizer
                                ^
Main.java:4: error: ';' expected
import scala.collection.mutable
                               ^
Main.java:5: error: ';' expected
import scala.util.Sorting
                         ^
Main.java:6: error: <identifier> expected
import math.{abs, max, min}
            ^
Main.java:7: error: <identifier> expected
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
                                ^
Main.java:8: error: ';' expected
import scala.reflect.ClassTag
                             ^
Main.java:68: error: '{' expected
  class InputReader(val stream: InputStream) {
                   ^
Main.java:69: error: ';' expected
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
                                                                                 ^
Main.java:70: error: 'var' is not allowed here
    private var tokenizer: StringTokenizer = _
            ^
Main.java:70: error: ';' expected
    private var tokenizer: StringTokenizer = _
                         ^
Main.java:70: error: <identifier> expected
    private var tokenizer: StringTokenizer = _
                                          ^
Main.java:70: error: as of release 9, '_' is a keyword, and may not be used as an identifier
    private var tokenizer: StringTokenizer = _
                                             ^
Main.java:70: error: ';' expected
    private var tokenizer: StringTokenizer = _
                                              ^
Main.java:72: error: ';' expected
    def next(): String = {
              ^
Main.java:74: error: ';' expected
        tokenizer = new StringTokenizer(reader.readLine)
                                                        ^
Main.java:75: error: not a statement
      tokenizer.nextToken
               ^
Main.java:75: error: ';' expected
      tokenizer.nextToken
                         ^
Main.java:78: error: ';' expected
    def nextInt(): Int = next().toInt
                 ^
Main.java:82: error: unnamed classes are a preview feature and are disabled by default.
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
  ^
  (use --enable-preview to enable unnamed classes)
Main.java:82: error: <identifier> expected
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
           ^
Main.java:83: error: ';' expected
    var i = offset
                  ^
Main.java:84: error: ';' expected
    val N = n + offset
                      ^
Main.java:85: error: ';' expected
    while(i < N) { f(i); i += 1 }
                               ^
Main.java:87: error: <identifier> expected
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
             ^
Main.java:88: error: ';' expected
    var i = n - 1 + offset
                          ^
Main.java:89: error: ';' expected
    while(i >= offset) { f(i); i -= 1 }
                                     ^
Main.java:92: error: class, interface, enum, or record expected
  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
  ^
Main.java:92: error: class, interface, enum, or record expected
  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
                       ^
Main.java:98: error: '{' expected
  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
                          ^
Main.java:100: error: ']' expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                 ^
Main.java:100: error: <identifier> expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                  ^
Main.java:100: error: <identifier> expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                            ^
Main.java:100: error: <identifier> expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                               ^
Main.java:100: error: <identifier> expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                                  ^
Main.java:100: error: illegal start of expression
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                                    ^
Main.java:100: error: ';' expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                                       ^
Main.java:100: error: ']' expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                                                 ^
Main.java:100: error: ';' expected
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
                                                  ^
Main.java:101: error: ';' expected
      if (as.nonEmpty) Some(as.maxBy(f)) else None
                                        ^
Main.java:101: error: not a statement
      if (as.nonEmpty) Some(as.maxBy(f)) else None
                                              ^
Main.java:101: error: ';' expected
      if (as.nonEmpty) Some(as.maxBy(f)) else None
                                                  ^
Main.java:104: error: ']' expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
              ^
Main.java:104: error: <identifier> expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
               ^
Main.java:104: error: <identifier> expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                  ^
Main.java:104: error: <identifier> expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                     ^
Main.java:104: error: illegal start of expression
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                       ^
Main.java:104: error: ';' expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                          ^
Main.java:104: error: ']' expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                                         ^
Main.java:104: error: ']' expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                                                        ^
Main.java:104: error: <identifier> expected
    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
                                                         ^
Main.java:105: error: ']' expected
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
                                   ^
Main.java:105: error: ']' expected
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
                                                 ^
Main.java:105: error: ';' expected
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
                                                  ^
Main.java:106: error: ';' expected
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
                    ^
Main.java:106: error: illegal start of expression
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
                        ^
Main.java:106: error: ';' expected
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
                                                                               ^
Main.java:107: error: not a statement
      map
      ^
Main.java:107: error: ';' expected
      map
         ^
Main.java:110: error: ']' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
              ^
Main.java:110: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
               ^
Main.java:110: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                  ^
Main.java:110: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                     ^
Main.java:110: error: illegal start of expression
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                       ^
Main.java:110: error: ';' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                          ^
Main.java:110: error: ';' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                                        ^
Main.java:110: error: ']' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                                                  ^
Main.java:110: error: ';' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                                                   ^
Main.java:110: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                                                        ^
Main.java:111: error: '}' expected
      var sum = num.zero
         ^
Main.java:111: error: <identifier> expected
      var sum = num.zero
             ^
Main.java:111: error: ';' expected
      var sum = num.zero
                        ^
Main.java:112: error: invalid method declaration; return type required
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      ^
Main.java:112: error: <identifier> expected
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
                   ^
Main.java:112: error: ';' expected
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
                    ^
Main.java:116: error: class, interface, enum, or record expected
    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
    ^
Main.java:140: error: '{' expected
  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
                             ^
Main.java:141: error: ']' expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
              ^
Main.java:141: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
               ^
Main.java:141: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                  ^
Main.java:141: error: <identifier> expected
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
                     ^
Main.java:141: error: illegal start of expression
    def sumBy[B](f: A => B)(implicit num: