output_description: Print the sum of the scores over all possible permutations, modulo 10^9+7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: import sys
  
  input = lambda: sys.stdin.readline().rstrip()
  sys.setrecursionlimit(max(1000, 10**9))
  write = lambda x: sys.stdout.write(x + "\n")
  
  
  n = int(input())
  
  M = 10**9 + 7  # 出力の制限
  N = n + 3  # 必要なテーブルサイズ
  
  g1 = [None] * (N + 1)  # 元テーブル
  g2 = [None] * (N + 1)  # 逆元テーブル
  inverse = [None] * (N + 1)  # 逆元テーブル計算用テーブル
  g1[0] = g1[1] = g2[0] = g2[1] = 1
  inverse[0], inverse[1] = [0, 1]
  
  for i in range(2, N + 1):
      g1[i] = (g1[i - 1] * i) % M
      inverse[i] = (
          -inverse[M % i] * (M // i)
      ) % M  # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
      g2[i] = (g2[i - 1] * inverse[i]) % M
  
  
  def cmb(n, r, M):
      if r < 0 or r > n:
          return 0
      r = min(r, n - r)
      return (g1[n] * g2[r] * g2[n - r]) % M
  
  
  ans = 0
  prev = 0
  # s = 0
  for i in range((n + 1) // 2, n):
      tmp = cmb(i - 1, n - i - 1, M) * g1[i] * g1[n - 1 - i]
      ans += i * (tmp - prev)
      prev = tmp
      #     print(i, tmp, g1[i], g1[n-1-i])
      ans %= M
  print(ans)
  
problem_description: Statement
  
  There are N squares lining up in a row, numbered 1 through N from left to
  right. Initially, all squares are white. We also have N-1 painting machines,
  numbered 1 through N-1. When operated, Machine i paints Square i and i+1
  black.
  
  Snuke will operate these machines one by one. The order in which he operates
  them is represented by a permutation of (1, 2, ..., N-1), P, which means that
  the i-th operated machine is Machine P_i.
  
  Here, the _score_ of a permutation P is defined as the number of machines that
  are operated before all the squares are painted black for the first time, when
  the machines are operated in the order specified by P. Snuke has not decided
  what permutation P to use, but he is interested in the scores of possible
  permutations. Find the sum of the scores over all possible permutations for
  him. Since this can be extremely large, compute the sum modulo 10^9+7.
samples: [{"input": "4", "output": "16\n    \n\nThere are six possible permutations as P. Among them, P = (1, 3, 2) and P =\n(3, 1, 2) have a score of 2, and the others have a score of 3. Thus, the\nanswer is 2 \\times 2 + 3 \\times 4 = 16.\n\n* * *"}, {"input": "2", "output": "1\n    \n\nThere is only one possible permutation: P = (1), which has a score of 1.\n\n* * *"}, {"input": "5", "output": "84\n    \n\n* * *"}, {"input": "100000", "output": "341429644"}]