A permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutation ($n=3$ but there is $4$ in the array).

Consider a permutation $p$ of length $n$, we build a graph of size $n$ using it as follows:   For every $1 \leq i \leq n$, find the largest $j$ such that $1 \leq j < i$ and $p_j > p_i$, and add an undirected edge between node $i$ and node $j$  For every $1 \leq i \leq n$, find the smallest $j$ such that $i < j \leq n$ and $p_j > p_i$, and add an undirected edge between node $i$ and node $j$ 

In cases where no such $j$ exists, we make no edges. Also, note that we make edges between the corresponding indices, not the values at those indices.

For clarity, consider as an example $n = 4$, and $p = [3,1,4,2]$; here, the edges of the graph are $(1,3),(2,1),(2,3),(4,3)$.

A permutation $p$ is cyclic if the graph built using $p$ has at least one simple cycle. 

Given $n$, find the number of cyclic permutations of length $n$. Since the number may be very large, output it modulo $10^9+7$.

Please refer to the Notes section for the formal definition of a simple cycle


-----Input-----

The first and only line contains a single integer $n$ ($3 \le n \le 10^6$).


-----Output-----

Output a single integer $0 \leq x < 10^9+7$, the number of cyclic permutations of length $n$ modulo $10^9+7$.


-----Examples-----
Input
4

Output
16
Input
583291

Output
135712853


-----Note-----

There are $16$ cyclic permutations for $n = 4$. $[4,2,1,3]$ is one such permutation, having a cycle of length four: $4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow 4$.

Nodes $v_1$, $v_2$, $\ldots$, $v_k$ form a simple cycle if the following conditions hold:   $k \geq 3$.  $v_i \neq v_j$ for any pair of indices $i$ and $j$. ($1 \leq i < j \leq k$)  $v_i$ and $v_{i+1}$ share an edge for all $i$ ($1 \leq i < k$), and $v_1$ and $v_k$ share an edge.

Source: codeforces | Difficulty: MEDIUM
Tags: Dynamic programming

Graph algorithms

Combinatorics

Mathematics


Solutions:
import sys
input = sys.stdin.readline
mod = 1000000007
n = int(input())
s = 1
for i in range(n):
	s *= i + 1
	s %= mod
neg = 1
for i in range(n - 1):
	neg *= 2
	neg %= mod
s -= neg
s %= mod
print(s)


import math
n = int(input())
m = 1
for i in range(2, n + 1):
	m = m * i
	m = m % 1000000007
x = 1
for i in range(n - 1):
	x = x * 2
	x = x % 1000000007
print((m - x) % 1000000007)


n = int(input())
mod = 10 ** 9 + 7
factorials = [1]
current = 1
for i in range(1, n + 1):
	current = current * i % mod
inverses = []
ans = current
ans = (ans - pow(2, n - 1, mod)) % mod
print(ans)


n = int(input())
f = n
p = 1
n -= 1
m = 10 ** 9 + 7
while n:
	f *= n
	p *= 2
	f %= m
	p %= m
	n -= 1
print((f - p) % m)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	n = int(inputi())
	p = 2
	c = 0
	for i in range(3, n + 1):
		c = (p * (i - 2) + c * 2) % 1000000007
		p = p * i % 1000000007
	print(c)
main()


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
sys.setrecursionlimit(300000)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
n = int(input())
ans = 0
t = 2
fact = 2
r = n - 3
for i in range(n - 2):
	ans += fact * (t - 1) % mod * pow(2, r, mod) % mod
	ans %= mod
	t += 1
	fact *= t
	fact %= mod
	r -= 1
print(ans)


import math

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
mod = 10 ** 9 + 7
fact = modFact(n, mod)
power = pow(2, n - 1, mod)
result = (fact - power) % mod
print(result)


from sys import stdin, exit
from bisect import bisect_left as bl, bisect_right as br
input = lambda : stdin.readline()[:-1]
intput = lambda : int(input())
sinput = lambda : input().split()
intsput = lambda : map(int, sinput())

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
mod = 10 ** 9 + 7
n = intput()
factorials = [1, 1]
for i in range(2, n):
	factorials.append(factorials[-1] * i % mod)
ans = 0
for sub in range(n - 2, 0, -1):
	ans += factorials[n - sub] * (n - sub - 1) % mod
	ans %= mod
	if sub != 1:
		ans *= 2
		ans %= mod
print(ans)


mod = 10 ** 9 + 7

def factorial(n):
	dp = [1 for x in range(n)]
	for i in range(2, n):
		dp[i] = i % mod * (dp[i - 1] % mod) % mod
	return dp

def circular(n):
	if n == 3:
		return 2
	multiplier = 1
	sum = 0
	i = 0
	fact = factorial(n)
	while True:
		x = n - 2 - i
		y = fact[n - 1 - i] % mod
		i += 1
		z = x % mod * (y % mod) * (multiplier % mod) % mod
		multiplier = multiplier * 2 % mod
		sum = (sum % mod + z % mod) % mod
		if x == 1:
			break
	return sum
t = int(input())
print(circular(t))


n = int(input())
m = 10 ** 9 + 7
fac = 1
for i in range(1, n + 1):
	fac = fac * i % m
print((fac - pow(2, n - 1, m)) % m)


from sys import stdin
import math
inp = lambda : stdin.readline().strip()

def modinv(a, m):
	(g, x, y) = egcd(a, m)
	if g != 1:
		return None
	else:
		return x % m

def factorialMod(n, modulus):
	ans = 1
	if n <= modulus // 2:
		for i in range(1, n + 1):
			ans = ans * i % modulus
	else:
		for i in range(1, modulus - n):
			ans = ans * i % modulus
		ans = modinv(ans, modulus)
		if n % 2 == 0:
			ans = -1 * ans + modulus
	return ans % modulus
n = int(inp())
print((factorialMod(n, 10 ** 9 + 7) - pow(2, n - 1, 10 ** 9 + 7)) % (10 ** 9 + 7))


n = int(input())
mod = 10 ** 9 + 7

def pow(x, y):
	if y == 0:
		return 1
	ans = pow(x, y // 2) % mod
	ans1 = ans * ans % mod
	if y & 1 == 1:
		return ans1 * x % mod % mod
	return ans1 % mod

def solve(n):
	dp = [0] * (n + 1)
	dp[0] = 1
	dp[2] = 2
	for i in range(3, n + 1):
		dp[i] = i * dp[i - 1] % mod
	return dp[n]
print((solve(n) % mod - pow(2, n - 1) % mod) % mod)


mod = 10 ** 9 + 7
n = int(input())
x = 1
for i in range(2, n + 1):
	x = x * i % mod
print((x - 2 ** (n - 1)) % mod)


import sys
import heapq

def main():
	n = int(input())
	modVal = 10 ** 9 + 7
	ans = [0] * (n + 1)
	ans[3] = 4
	ansVal = 1
	diffVal = 1
	for i in range(1, n + 1):
		ansVal *= i
		ansVal %= modVal
	for i in range(1, n):
		diffVal *= 2
		diffVal %= modVal
	ansVal -= diffVal
	ansVal %= modVal
	print(ansVal)
	return
main()


n = int(input())
pr = 1
mod = 10 ** 9 + 7
dif = 1 / 2
for i in range(1, n + 1):
	pr = pr * i % mod
	dif = int(dif * 2) % mod
if pr < dif:
	pr += mod
print(pr - dif)


MOD = 1000000007

def binpow(a, b):
	if b == 0:
		return 1
	val = binpow(a, int(b / 2))
	if b % 2 == 0:
		return val * val % MOD
	else:
		return val * val * a % MOD
n = int(input())
fact = [1, 1]
for i in range(2, n + 1):
	fact.append(fact[i - 1] * i % MOD)
res = (fact[n] - binpow(2, n - 1)) % MOD
print(res)


n = int(input())

def fact(n, mod):
	res = 1
	while n > 1:
		temp = 1
		if n // mod % 2:
			temp = n - 1
		res = res * temp % mod
		for i in range(2, n % mod + 1):
			res = res * i % mod
		n = n // mod
	return res % mod
MOD = int(1000000000.0 + 7)
factorial = fact(n, MOD)
power = 1 << n - 1
print((factorial - power) % MOD)


n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = i * ans % (10 ** 9 + 7)
print((ans - 2 ** (n - 1) % (10 ** 9 + 7)) % (10 ** 9 + 7))


import os
from io import BytesIO, IOBase
import sys
MOD = 10 ** 9 + 7

def main():
	n = int(input())
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % MOD
	ans = (ans - pow(2, n - 1, MOD)) % MOD
	print(ans)
	return
BUFSIZE = 1048576

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
cc = 1
for i in range(n):
	cc = cc * (i + 1) % 1000000007
cc = (cc - pow(2, n - 1, 1000000007)) % 1000000007
print(cc)


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
MOD = 10 ** 9 + 7
T = 1
for _ in range(T):
	n = int(stdin.readline())
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % MOD
	p2 = pow(2, n - 1, MOD)
	print((fac - p2) % MOD)


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mod = 1000000007
n = int(input())
res = 1
for i in range(n):
	res = res % mod * (i + 1) % mod
ans = 1
for i in range(n - 1):
	ans = ans * 2 % mod
print((res - ans + mod) % mod)


MOD = 1000000007

def qmi(a, b):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % MOD
		a = a * a % MOD
		b >>= 1
	return ans

def jie(n):
	ans = 1
	for i in range(n):
		ans = ans * (i + 1) % MOD
	return ans
n = int(input())
ans = (jie(n) % MOD - qmi(2, n - 1) % MOD) % MOD
print(ans)


(z, zz, dgraphs, mod) = (input, lambda : list(map(int, z().split())), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
print((ans - 2 ** (n - 1)) % mod)


def me(base, exp, mod):
	if exp == 0:
		return 1
	if exp % 2 == 0:
		r = me(base, exp / 2, mod)
		return r * r % mod
	else:
		return base % mod * me(base, exp - 1, mod) % mod

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
p = 1000000007
fact = modFact(n, p)
exp = me(2, n - 1, p)
print((fact - exp + p) % p)


Q = 10 ** 9 + 7

def main():
	n = int(input())
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= Q
	ans = (ans - pow(2, n - 1, Q)) % Q
	print(ans)
main()


import sys, math, cmath, time
start_time = time.time()

def solve():
	n = inp()
	q = 1
	w = 1
	for i in range(n, 0, -1):
		q = q * i % 1000000007
		if i != 1:
			w = 2 * w % 1000000007
	print((q - w) % 1000000007)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def range_prod(lo, hi):
	if lo + 1 < hi:
		mid = (hi + lo) // 2
		return range_prod(lo, mid) * range_prod(mid + 1, hi)
	if lo == hi:
		return lo
	return lo * hi

def treefactorial(n):
	if n < 2:
		return 1
	return range_prod(1, n)

def pow(x, y):
	if y == 1:
		return x
	if y == 0:
		return 1
	temp = pow(x, y // 2)
	temp *= temp
	if y & 1:
		temp *= x
	return temp

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


MOD = 1000000007
ans = 1
n = int(input())
for i in range(1, n + 1):
	ans *= i
	ans %= MOD
ans -= pow(2, n - 1)
ans %= MOD
print(ans)


def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def modPower(x, y, mod):
	res = 1
	x = x % mod
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % mod
		y = y >> 1
		x = x * x % mod
	return res
n = int(input())
a = modFact(n, 1000000007)
b = modPower(2, n - 1, 1000000007)
print((a - b) % 1000000007)


mod = 10 ** 9 + 7
n = int(input())
t2 = pow(2, n - 1, mod)
t = 1
for i in range(1, n + 1):
	t = t * i % mod
print((t - t2) % mod)


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(stdin.readline())
M = 10 ** 9 + 7
dp = [1] * (n + 1)
for i in range(1, n + 1):
	dp[i] = dp[i - 1] * i % M
ans = power(2, n - 1, M)
print((dp[n] - ans) % M)


import sys
input = sys.stdin.readline
LI = lambda : list(map(int, input().strip('\n').split()))
MI = lambda : map(int, input().strip('\n').split())
SI = lambda : input().strip('\n')
II = lambda : int(input().strip('\n'))
n = II()
(a, b, m) = (1, 1, int(1000000000.0 + 7))
for i in range(1, n):
	a = a * i % m
	b = b * 2 % m
a = a * n % m
print((a - b) % m)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
n = int(input())
mod = 10 ** 9 + 7
two = 1
prod = 1
for i in range(1, n + 1):
	prod *= i
	prod %= mod
for i in range(1, n):
	two *= 2
	two %= mod
print((prod - two) % mod)


MOD = 10 ** 9 + 7
n = int(input())
fac = [1] * (n + 1)
dp = [0] * (n + 1)
for i in range(1, n + 1):
	fac[i] = fac[i - 1] * i % MOD
for i in range(3, n + 1):
	a = i * (i - 1) // 2
	b = (a * 2 - 4) % MOD * fac[i - 2]
	c = 4 * dp[i - 2] % MOD
	ans = (b + c) % MOD
	dp[i] = ans
print(dp[n])


pri = pow(10, 9) + 7
ans = [1, 1]
for i in range(2, pow(10, 6) + 1):
	ans.append(ans[-1] * i)
	ans[-1] %= pri
s = int(input())
x = pow(2, s - 1, pri)
print((ans[s] - x) % pri)


import sys
M = 10 ** 9 + 7

def fmodM(n):
	if n >= M:
		return 0
	result = 1
	for i in range(2, n + 1):
		result = result * i % M
	return result

def answer(n):
	total = fmodM(n)
	acyclic = 2 ** (n - 1) % M
	return (total - acyclic) % M

def main():
	n = int(sys.stdin.readline())
	print(answer(n))
	return
main()


import sys
M = 1000000007

def main():
	n = int(sys.stdin.readline())
	a = 1
	for i in range(1, n + 1):
		a = a * i % M
	print((a + M - pow(2, n - 1, M)) % M)
main()


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
mod = 1000000007

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i % mod
	return res
n = inputnum()
print((fact(n) - pow(2, n - 1, mod) + mod) % mod)


n = int(input())
mod = 1000000007
res = 1
for i in range(1, n + 1):
	res = res * i % mod
res = (res - pow(2, n - 1, mod) + mod) % mod
print(res)


n = int(input())
modulus = 10 ** 9 + 7
t = 1
for i in range(1, n + 1):
	t = t * i % modulus
result = int((t - 2 ** (n - 1)) % modulus)
print(result)


from sys import stdin, stdout
mod = 1000000007
n = int(stdin.readline())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
ans = (ans - pow(2, n - 1, mod)) % mod
print(ans)


a = 1
m = 10 ** 9 + 7
f = [1] * 1000001
for i in range(1, 1000001):
	a *= i
	a %= m
	f[i] = a
n = int(input())
a = f[n]
b = pow(2, n - 1, m)
if a >= b:
	print(a - b)
else:
	print(a + m - b)


n = int(input())
r = 10 ** 9 + 7
s = 0
p1 = 1
p2 = 1
for i in range(1, n):
	p1 = p1 * i % r
	p2 = 2 * p2 % r
p1 = p1 * n % r
s = (r + p1 - p2) % r
print(s)


mod = 10 ** 9 + 7
n = int(input())
total = 1
for i in range(1, n + 1):
	total *= i
	total %= mod
total -= pow(2, n - 1, mod)
total %= mod
print(total)


n = int(input().strip())
mod = 10 ** 9 + 7
power = 1
fac = 1
for i in range(2, n + 1):
	power = power * 2 % mod
	fac = fac * i % mod
print((fac - power) % mod)


mod = 10 ** 9 + 7

def power(x, a):
	if a == 0:
		return 1
	z = power(x, a // 2)
	z = z * z % mod
	if a % 2:
		z = z * x % mod
	return z

def fact(n):
	prod = 1
	for no in range(2, n + 1):
		prod = prod * no % mod
	return prod
n = int(input())
val = fact(n) - power(2, n - 1)
print(val + (10 ** 9 + 7) * int(val < 0))


n = int(input())
modulo = 10 ** 9 + 7
f = 1
for i in range(n):
	f = f * (i + 1) % modulo
print((f - 2 ** (n - 1)) % modulo)


n = int(input())
mod = pow(10, 9) + 7
fact = 1
for i in range(2, n + 1):
	fact *= i
	fact %= mod
fact %= mod
expo = pow(2, n - 1) % mod
print((fact - expo) % mod)


n = int(input())
c = 1
for i in range(1, n + 1):
	c = c * i % (10 ** 9 + 7)
k = 2 ** (n - 1)
c = c - k
print(c % (10 ** 9 + 7))


MOD = 10 ** 9 + 7

def a(n):
	return (3 * MOD + factorial(n) - pow(2, n - 1, MOD)) % MOD

def factorial(n):
	p = 1
	for i in range(1, n + 1):
		p = p * i % MOD
	return p
print(a(int(input())))


import bisect
import sys
import math
input = sys.stdin.readline
import functools
from collections import defaultdict

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve(case):
	n = inp()
	M = 10 ** 9 + 7
	total = 1
	for i in range(n):
		total = total * (n - i) % M
	no_cycle = 1
	for i in range(n - 1):
		no_cycle = no_cycle * 2 % M
	return (total + M - no_cycle) % M
if len(sys.argv) > 1 and sys.argv[1].startswith('input'):
	f = open('./' + sys.argv[1], 'r')
	input = f.readline
res = solve(0)
print(str(res))


mod = 1000000007

def qmod(a, b, mod):
	a = a % mod
	ans = 1
	while b != 0:
		if b & 1:
			ans = ans * a % mod
		b >>= 1
		a = a * a % mod
	return ans
n = int(input())
fac = 1
for i in range(1, n + 1):
	fac = fac * i % mod
print(((fac - qmod(2, n - 1, mod)) % mod + mod) % mod)


def modf(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % Mod
	return result

def pernm(n, p):
	return (pow(2, n - 1) - 2) % Mod
n = int(input())
Mod = 10 ** 9 + 7
a = modf(n, Mod)
print((a - pernm(n, Mod) - 2) % Mod)


M = 10 ** 9 + 7

def factorial(N):
	Ans = 1
	for i in range(N, 1, -1):
		Ans *= i
		Ans %= M
	return Ans
N = int(input())
X = factorial(N)
Minus = pow(2, N - 1, M)
print((X - Minus) % M)


n = int(input())
ans = 0
x = 1
for i in range(2, n + 1):
	x = x * i % (10 ** 9 + 7)
y = 1
for i in range(n - 1):
	y = 2 * y % (10 ** 9 + 7)
ans = (x - y) % (10 ** 9 + 7)
print(ans)


n = int(input())
mod = 10 ** 9 + 7
perms = 1
noncyc = 1
for i in range(2, n + 1):
	perms = perms * i % mod
	noncyc = noncyc * 2 % mod
res = perms - noncyc
if res < 0:
	print(res + mod)
else:
	print(res)


lst = [0, 0, 4, 8]
mod = 10 ** 9 + 7
for i in range(4, 10 ** 6 + 1):
	lst.append(lst[-1] * 2 % mod)

def main(case):
	n = int(input())
	sm = 1
	for i in range(2, n + 1):
		sm *= i
		sm %= mod
	print((sm - lst[n - 1]) % mod)
t = 1
for i in range(t):
	main(i + 1)


res = 1
pr = 1
n = int(input())
for i in range(1, n + 1):
	res = res * i % 1000000007
	if i != 1:
		pr = pr * 2 % 1000000007
pr %= 1000000007
res = (res - pr) % 1000000007
print(res)


mo = 10 ** 9 + 7
n = int(input())
f = 1
for i in range(1, n + 1):
	f *= i
	f %= mo
ans = f - pow(2, n - 1, mo)
print(ans % mo)


M = 10 ** 9 + 7
n = int(input())
f = 1
i = n
while i:
	f = f * i % M
	i -= 1
print((f - pow(2, n - 1, M)) % M)


def fac(x):
	ans = 1
	mod = 10 ** 9
	mod += 7
	for i in range(1, x + 1):
		ans *= i
		ans %= mod
	return ans
n = int(input())
mod = 10 ** 9
mod += 7
facn = fac(n)
c2pn = pow(2, n - 1, mod)
print((facn - c2pn) % mod)


def solve():
	n = int(input())
	P = 1000000007
	noc = 2 ** (n - 1) % P
	al = 1
	for i in range(2, n + 1):
		al = al * i
		al %= P
	ans = (al - noc + P) % P
	print(ans)

def main():
	solve()

def cases():
	for _ in range(int(input())):
		solve()
main()


fact = [1]
pow_2 = [1]
MOD = 1000000007
for i in range(1, 1000001):
	fact.append(fact[-1] * i % MOD)
	pow_2.append(pow_2[-1] * 2 % MOD)
for _ in range(1):
	n = int(input())
	print((fact[n] - pow_2[n - 1]) % MOD)


n = int(input())
n_fact = 1
for i in range(1, n + 1):
	n_fact = n_fact * i
	n_fact %= 1000000007
dif = 1
for i in range(1, n):
	dif *= 2
	dif %= 1000000007
answer = n_fact - dif
if answer < 0:
	answer += 1000000007
answer %= 1000000007
print(answer)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from bisect import bisect_left, bisect_right
MOD = int(1000000000.0) + 7
LOAD = int(1000000.0) + 3

class Sequential:

	def __init__(self, data=None):
		if data is None:
			data = [1]
		self.data = data

	def __getitem__(self, item):
		if isinstance(item, slice):
			last = item.stop - 1
		else:
			last = item
		if last > LOAD:
			return self.__call__(item)
		if len(self) <= last:
			self.resize(last + 1)
		return self.data[item]

	def resize(self, n):
		del self.data[n:]
		length = len(self)
		self.data.extend([None] * (n - length))
		for i in range(length, n):
			self.data[i] = self.next(self.data[i - 1])

	def resize_with_value(self, value):
		if self.data[-1] < value:
			while True:
				self.data.append(self.next(self.data[-1]))
				if self.data[-1] >= value:
					return self.data[-1]

	@staticmethod
	def next(a_n):
		return NotImplemented

	def prev(self, a_n):
		return self.lower(a_n)

	def bisect_left(self, value):
		self.resize_with_value(value)
		return bisect_left(self.data, value)

	def bisect_right(self, value):
		self.resize_with_value(value)
		return bisect_right(self.data, value)

	def ceil(self, value):
		return self.data[self.bisect_left(value)]

	def higher(self, value):
		index = self.bisect_left(value)
		ceil = self.data[index]
		return self[index + 1] if ceil == value else ceil

	def floor(self, value):
		if value < self.data[0]:
			return None
		return self.data[self.bisect_right(value) - 1]

	def lower(self, value):
		index = self.bisect_left(value)
		return None if index == 0 else self.data[index - 1]

	def __len__(self):
		return len(self.data)

	def __call__(self, item):
		return NotImplemented

def A011782(n=None, mod=MOD):
	if n is not None:
		return pow(2, n, mod)

	class Seq(Sequential):

		@staticmethod
		def next(a_n):
			return (a_n << 1) % mod

		@staticmethod
		def __call__(n_, mod_=MOD):
			return pow(n_, mod_)
	return Seq()

def A000142(n=None, mod=MOD):
	if n is not None:
		r = 1
		for i in range(2, n + 1):
			r = r * i % mod
		return r

	class Seq(Sequential):

		def resize(self, n):
			del self.data[n:]
			length = len(self)
			self.data.extend([None] * (n - length))
			for i in range(length, n):
				self.data[i] = self.data[i - 1] * i % mod
	return Seq()

def A059204(n=None, mod=MOD):
	if n is not None:
		return (A000142(n, mod) - A011782(n - 1)) % mod

	class Seq(Sequential):

		def __init__(self):
			self.A000142 = A000142()
			self.A011782 = A011782()
			super().__init__([0, 0, 0, 2])

		def resize(self, n):
			del self.data[n:]
			self.A000142.resize(n)
			self.A011782.resize(n)
			length = len(self)
			self.data.extend([None] * (n - length))
			for i in range(length, n):
				self.data[i] = self.A000142[i] - self.A011782[i - 1]
	return Seq()
print(A059204(itg()))


mod = 10 ** 9 + 7
n = int(input())
answer = 1
for i in range(1, n + 1):
	answer = answer * i % mod
temp = 2 ** (n - 1) % mod
res = answer - temp
print(res % mod)


def fact(n):
	r = 1
	for i in range(2, n + 1):
		r = r * i
		r %= 1000000007
	return r
n = int(input())

def pow(n):
	r = 1
	for i in range(n):
		r *= 2
		r %= 1000000007
	return r
print((fact(n) - pow(n - 1) + 1000000007) % 1000000007)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
N = 1000001
p = 10 ** 9 + 7
fact = [None] * (N + 1)
fact[0] = 1
for i in range(1, N + 1):
	fact[i] = fact[i - 1] * i % p

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		print((fact[n] + p - pow(2, n - 1, p)) % p)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


m = 10 ** 9 + 7
n = int(input())
fact = 1
for i in range(1, n + 1):
	fact = fact * i % m
pow_of_two = 2
two_n = 1
act = n - 1
while act > 0:
	if act % 2 == 1:
		two_n = two_n * pow_of_two % m
	act //= 2
	pow_of_two = pow_of_two ** 2 % m
ans = (fact - two_n) % m
print(ans)


n = int(input())
u = 0
BIG = int(1000000000.0 + 7)
memo = {}

def factorial(x):
	if x not in memo:
		i = 1
		for k in range(1, x + 1):
			i *= k
			i %= BIG
		memo[x] = i
	return memo[x]
u = factorial(n) - pow(2, n - 1, BIG)
u %= BIG
print(u)


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
mod = 10 ** 9 + 7
n = int(input())
(p, q) = (1, 1)
for i in range(1, n + 1):
	p = p * i % mod
print((p - 2 ** (n - 1)) % mod)


import math
n = int(input())
mod = 10 ** 9 + 7
x = 1
if n >= mod:
	x = 0
else:
	for i in range(1, n + 1):
		x = x * i % mod
y = 2 ** (n - 1) % mod
print((x - y) % mod)


from math import factorial as fac
p = 10 ** 9 + 7
n = int(input())
f = [1]
for i in range(1, n + 1):
	f.append(f[-1] * i % p)
print((f[n] - pow(2, n - 1, p)) % p)


M = 10 ** 9 + 7

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
print((modFact(n, M) - pow(2, n - 1, M)) % M)


import math
n = int(input())
mod = 10 ** 9 + 7

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
x = modFact(n, mod)
y = 2 ** (n - 1) % mod
print((x - y) % mod)


n = int(input())
dp = {}
dp[1] = 0
dp[2] = 0
dp[3] = 2
mod = 1000000007
fact = {}
fact[1] = 1
fact[2] = 2
fact[3] = 6
p = 2

def largestPower(n, p):
	x = 0
	while n:
		n //= p
		x += n
	return x

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def modFact(n, p):
	if n >= p:
		return 0
	res = 1
	isPrime = [1] * (n + 1)
	i = 2
	while i * i <= n:
		if isPrime[i]:
			for j in range(2 * i, n, i):
				isPrime[j] = 0
		i += 1
	for i in range(2, n):
		if isPrime[i]:
			k = largestPower(n, i)
			res = res * power(i, k, p) % p
	return res
for i in range(3, n + 1):
	fact[i] = fact[i - 1] * i % mod
print((fact[n] - power(2, n - 1, mod)) % mod)


def ca(n):
	ma = 1000000007
	va = 1
	for i in range(1, n + 1):
		va *= i % ma
		va = va % ma
	ca = pow(2, n - 1) % ma
	return (va - ca) % ma
n = int(input())
y = ca(n)
print(y)


import math
import time
from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import PriorityQueue
import sys
n = int(input())
MOD = 1000000007
ans = 1
for i in range(1, n + 1):
	ans *= i
	ans %= MOD
ans -= pow(2, n - 1, MOD)
print(ans % MOD)


import math

def next_int():
	return int(input())
n = next_int()
mod = 1000000000 + 7
combinations = 1
for i in range(1, n + 1):
	combinations = combinations * i % mod
combinations -= 2 ** (n - 1) % mod
print(combinations % mod)


n = int(input())
MOD = int(1000000000.0) + 7
fact = 1
for i in range(1, n + 1):
	fact = fact * i
	fact %= MOD
res = fact + MOD - pow(2, n - 1, MOD)
print(res % MOD)


import sys
import heapq
import math
from collections import deque
from collections import defaultdict
from collections import Counter
modH = int(10 ** 9) + 7
I = lambda : list(map(int, input().split(' ')))

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
n = int(input())
if n >= 4:
	dp = [0] * (n + 1)
	mem = [0] * (n + 1)
	mem[0] = 1
	for i in range(1, n + 1):
		mem[i] = mem[i - 1] % modH * (i % modH) % modH
	dp[3] = 2
	m = n
	for n in range(4, m + 1):
		dp[n] = ((n - 2) % modH * (mem[n - 1] % modH) + 2 % modH * (dp[n - 1] % modH) % modH) % modH
	print(dp[-1])
elif n == 3:
	print(2)
else:
	print(0)


import sys
input = sys.stdin.readline
N = int(input())
mod = 10 ** 9 + 7

class Factorial:

	def __init__(self, n, mod):
		self.mod = mod
		self.f = [1]
		for i in range(1, n + 1):
			self.f.append(self.f[-1] * i % mod)
		self.i = [pow(self.f[-1], mod - 2, mod)]
		for i in range(1, n + 1)[::-1]:
			self.i.append(self.i[-1] * i % mod)
		self.i.reverse()

	def factorial(self, i):
		return self.f[i]

	def ifactorial(self, i):
		return self.i[i]

	def combi(self, n, k):
		return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod

	def permi(self, n, k):
		return self.f[n] * self.i[n - k] % self.mod
f = Factorial(N, mod)
print((f.factorial(N) - pow(2, N - 1, mod)) % mod)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()

def fact(n):
	global mod
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % mod
	return ans
t = 1
for _ in range(t):
	n = ip()
	ans = (fact(n) - pow(2, n - 1, mod)) % mod
	print(ans)


n = int(input())
res = 1
fact = 1
for i in range(1, n):
	res *= 2
	fact *= i
	res %= 10 ** 9 + 7
	fact %= 10 ** 9 + 7
fact *= n
fact %= 10 ** 9 + 7
fact -= res
fact %= 10 ** 9 + 7
if fact < 0:
	fact += 10 ** 9 + 7
print(fact)


for _ in range(1):
	n = int(input())
	if n == 3:
		print(2)
		continue
	ans = 1
	mod = 1000000007
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	print((ans - pow(2, n - 1, mod)) % mod)


n = int(input())
fact = 1
two = 1
for i in range(1, n + 1):
	fact *= i
	fact %= 1000000007
for i in range(1, n):
	two *= 2
	two %= 1000000007
print((fact - two) % 1000000007)


def factorial(n):
	M = 1000000007
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f
MOD = int(1000000000.0 + 7)
x = int(input())
ans = factorial(x) % MOD - pow(2, x - 1, MOD)
print(ans % MOD)


n = int(input())
(fact, modulo) = (1, 1000000007)
for i in range(2, n + 1):
	fact = fact * i % modulo
print((fact - pow(2, n - 1, modulo)) % modulo)


n = int(input())
x = 1
m = 1000000007
for i in range(1, n + 1):
	x *= i
	x %= m
y = 1
for i in range(n - 1):
	y *= 2
	y %= m
if x - y < 0:
	print(x - y + m)
else:
	print(x - y)


mod = 1000000007
n = int(input())
p = pow(2, n - 1, mod)
f = 1
for i in range(2, n + 1):
	f = f * i % mod
print((f - p) % mod)


import sys
import math
from collections import defaultdict as ddict
fast_inp = lambda : sys.stdin.readline().split('\n')[0]
read_list = lambda : fast_inp().split(' ')
read_listi = lambda : list(map(int, fast_inp().split(' ')))
read_listf = lambda : list(map(float, fast_inp().split(' ')))
read_int = lambda : int(fast_inp())
read_float = lambda : float(fast_inp())
read = lambda : fast_inp()
DEBUG = True

def debug(**kwargs):
	if not DEBUG:
		return
	print('*' * 20)
	for (k, v) in kwargs.items():
		print(f'\t{k}:{v}\t')
	print('*' * 20)
MOD = int(1000000000.0) + 7
factorial = [1, 1, 2]
for x in range(3, int(1000000.0) + 10):
	factorial.append(factorial[-1] * x % MOD)

def solve() -> None:
	n = read_int()
	print((factorial[n] - pow(2, n - 1, MOD)) % MOD)
t = 1
for _ in range(t):
	solve()


def answer(n):
	m = 10 ** 9 + 7
	dp = [0] * n
	c = 1
	for i in range(1, n + 1):
		c = c % m * (i % m) % m
	return (c - pow(2, n - 1, m)) % m
n = int(input())
print(answer(n))


n = int(input())
b = 2 ** (n - 1) % 1000000007
a = 1
for i in range(1, n + 1):
	a *= i
	a %= 1000000007
if a < b:
	a += 1000000007
print((a - b) % 1000000007)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7
n = int(data())
f = 1
for i in range(1, n + 1):
	f = f * i % mod
out((f - pow(2, n - 1, mod) + mod) % mod)


mod = 1000000007
n = int(input())
a = 1
for i in range(1, n + 1):
	a = a * i % mod
b = pow(2, n - 1, mod)
ans = (a - b + mod) % mod
print(ans)


mod = 1000000007
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans *= i
	ans %= mod
sub = 2
for i in range(3, n + 1):
	sub *= 2
	sub %= mod
k = (ans - sub) % mod
print(k)


n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % 1000000007
temp = 4
while n > 3:
	temp = temp * 2 % 1000000007
	n = n - 1
ans = (ans - temp + 1000000007) % 1000000007
print(ans)


n = int(input())
mod = 1
p = 10 ** 9 + 7
ans = 1
for i in range(1, n + 1):
	if i != n:
		mod = mod * 2 % p
	ans = ans * i % p
print((ans - mod) % p)


n = int(input())
v = 1
m = int(1000000000.0 + 7)
for i in range(1, n):
	v *= 2
	v = v % m
fact = [1]
for i in range(1, n + 1):
	val = fact[i - 1] * i
	val = val % m
	fact.append(val)
x = fact[n] - v
if x < 0:
	x += m
print(x)


def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
N = int(input())
Mod = 10 ** 9 + 7

def function(X):
	A = 1
	for i in range(X, 1, -1):
		A *= i
		A %= Mod
	return A
Rem = power(2, N - 1, Mod)
X = function(N)
print((X - Rem) % Mod)


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ri = lambda : int(sys.stdin.readline().strip())
rs = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
import random
from queue import PriorityQueue as pq
from math import ceil
n = ri()

def fact(n, mod):
	res = 1
	for i in range(1, n + 1):
		res = res * i % mod
	return res
mod = 1000000007
ans = fact(n, mod)
ans = ans - pow(2, n - 2, mod) * 2
ans = ans % mod
print(ans)


n = int(input())

def factorial(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= 10 ** 9 + 7
	return ans % (10 ** 9 + 7)
print((factorial(n) - 2 ** (n - 1) % (10 ** 9 + 7)) % (10 ** 9 + 7))


n = int(input())
v = 1
MOD = 10 ** 9 + 7
for i in range(1, n + 1):
	v *= i
	v %= MOD
v -= pow(2, n - 1, MOD)
v %= MOD
print(v)


import math
import sys
import bisect
input = sys.stdin.readline
t = 1
for _ in range(t):
	mod = 10 ** 9 + 7
	n = int(input())
	ans = 1
	x = 1
	for i in range(n - 1):
		x = 2 * (x % mod) % mod
	for i in range(1, n + 1):
		ans = i % mod * (ans % mod) % mod
	ans = (ans - x) % mod
	print(ans)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue

def factors(n):
	l = []
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def check1(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v -= 1

def check2(s, v, x):
	while True:
		if v not in s:
			return v
		else:
			v += 1

def up(n):
	j = n - 1
	while j > 0:
		if n % j == 0:
			break
		j -= 1
	return j

def fac(n):
	c = 1
	i = 1
	while i <= n:
		c *= i
		i += 1
	return c

def check_happy(n):
	ss = set()
	print(n)
	while n != 1:
		val = n
		s = 0
		print(val)
		while val != 0:
			s += (val % 10) ** 2
			val = val // 10
		print(val)
		print('hi')
		if val in ss:
			return False
		else:
			n = val
			ss.add(n)
	return True

def update(a, b):
	c = 1
	val = a
	while a < b:
		print(c, a)
		c += c
		a += a
	print(1)
	while a > b:
		print()
		a -= val
		c -= 1
	return c
import random as rand

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
from itertools import permutations

def insertion_sort(arr):
	for i in range(len(arr)):
		j = i
		while j > 0:
			if arr[j] < arr[j - 1]:
				temp = arr[j]
				arr[j] = arr[j - 1]
				arr[j - 1] = temp
			j -= 1
	return arr

def quick_sort(arr, low, high):
	i = low
	j = high
	while i < j:
		if arr[i] > arr[low] and arr[j] < arr[low]:
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = arr[i]
			i += 1
			j -= 1
		elif arr[i] <= arr[low]:
			i += 1
		elif arr[j] >= arr[low]:
			j -= 1
	print(i, j)
	toto = arr[j]
	arr[j] = arr[low]
	arr[low] = toto
	return j

def dodo(arr, low, high):
	if low < high:
		val = quick_sort(arr, low, high)
		dodo(arr, low, val - 1)
		dodo(arr, val + 1, high)

def dp(arr, c, n, k, z, ans):
	if k == 0:
		return ans
	elif c == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	elif c == n - 1:
		if z == 0:
			return 0
		else:
			return dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1])
	elif z == 0:
		return dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1])
	else:
		return max(dp(arr, c + 1, n, k - 1, z, ans + arr[c + 1]), dp(arr, c - 1, n, k - 1, z - 1, ans + arr[c - 1]))

def check(arr, val):
	a = -1
	for i in range(len(arr)):
		if arr[i][len(arr[i]) - 1] == val:
			a = i
			break
	return a

def reverse(s, i, ans):
	if i >= len(s):
		return ans
	else:
		return reverse(s, i + 1, s[i] + ans)

def update(arr, i, j, n, m):
	if i >= 0 and i < n and (j >= 0) and (j < m):
		if arr[i][j] == 1:
			arr[i][j] == 2
			return [i, j]
	return [-1, -1]
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % 1000000007
print((ans - 2 ** (n - 1) % 1000000007) % 1000000007)


def main():
	n = int(input())
	mod = 10 ** 9 + 7
	fact = 1
	for i in range(1, n + 1):
		fact *= i
		fact %= mod
	p = 1
	for i in range(n - 1):
		p *= 2
		p %= mod
	ans = (fact - p + mod * mod) % mod
	print(ans)
main()


import io, os
from collections import deque
import bisect
RL = lambda : list(map(int, input().split(' ')))
fact = 1
n = int(input())
m = 10 ** 9 + 7
ans = 0
for i in range(3, n + 1):
	fact = fact * (i - 2) % m
	ans = ((i - 1) % m * ((i - 2) % m) % m * fact % m + ans * 2 % m) % m
print(ans)


import math as m
n = int(input())
ans = 1
mod = 1000000000.0 + 7
for i in range(1, n + 1):
	ans *= i
	ans %= mod
p = 1
for i in range(1, n):
	p *= 2
	p %= mod
ans -= p
ans %= mod
print(int(ans))


def fact(x):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % (10 ** 9 + 7)
	return ans
n = int(input())
print((fact(n) - 2 ** (n - 1)) % (10 ** 9 + 7))


n = int(input())
f = 2
fac = 1
minus = 2
for i in range(n - 2):
	minus *= 2
	minus %= 1000000007
for i in range(1, n + 1):
	fac %= 1000000007
	fac *= i
print((fac - minus) % 1000000007)


m = pow(10, 9) + 7
n = int(input())
a = 2
fact = [1] * (n + 1)
po = [1] * (n + 1)
for i in range(1, n + 1):
	fact[i] = fact[i - 1] * i % m
	po[i] = 2 * po[i - 1] % m
print((fact[n] - po[n - 1]) % m)


def fact(n):
	ans = 1
	while n:
		ans *= n
		ans %= 10 ** 9 + 7
		n -= 1
	return ans

def binpow(n):
	ans = 1
	while n:
		ans *= 2
		ans %= 10 ** 9 + 7
		n -= 1
	return ans
n = int(input())
ans = fact(n) - binpow(n - 1)
ans %= 10 ** 9 + 7
print(ans)


n = int(input())
p = 10 ** 9 + 7
g = 1
for i in range(1, n + 1):
	g *= i
	g %= p
ans = (g + p - pow(2, n - 1)) % p
print(ans)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')
from itertools import permutations
from collections import deque

def has_cycle(n, g):
	for start in range(n):
		prev = [-1] * n
		t = [-1] * n
		q = deque()
		q.append(start)
		t[start] = 0
		while q:
			v = q.popleft()
			for w in g[v]:
				if t[w] != -1:
					if t[w] >= t[v]:
						return True
				else:
					t[w] = t[v] + 1
					prev[w] = v
					q.append(w)
	return False

def test(n, a):
	g = [[] for _ in range(n)]
	for i in range(n):
		j = i - 1
		while j >= 0 and a[j] < a[i]:
			j -= 1
		if j >= 0:
			g[i].append(j)
			g[j].append(i)
		j = i + 1
		while j < n and a[j] < a[i]:
			j += 1
		if j < n:
			g[i].append(j)
			g[j].append(i)
	return has_cycle(n, g)

def main():
	m = 1000000007
	n = ri()
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % m
	p2 = 1
	for i in range(n - 1):
		p2 = p2 * 2 % m
	ans = (ans - p2) % m
	wi(ans)
	return
main()


n = int(input())
fact = 1
MOD = 10 ** 9 + 7
for i in range(1, n + 1):
	fact = fact * i % MOD
print((fact - 2 ** (n - 1)) % MOD)


mod = 1000000007

def modFact(n):
	p = mod
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result % p
n = int(input())
dp = [0] * (n + 1)
dp[3] = 4
ans = [0] * (n + 1)
ans[3] = 2
for i in range(4, n + 1):
	dp[i] = 2 * dp[i - 1] % mod
print((modFact(n) - dp[n] + mod) % mod)


def fact(n):
	if n == 0:
		return 1
	M = 10 ** 9 + 7
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i
		ans %= M
	return ans

def ans(n):
	M = 10 ** 9 + 7
	answer = fact(n)
	answer = answer % M
	answer -= 2 ** (n - 1) % M
	answer = answer % M
	return answer
n = int(input())
print(int(ans(n)))


import sys
import math
input = sys.stdin.buffer.readline

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def solution():
	n = int(input())
	mod = 10 ** 9 + 7
	ans = 1
	for i in range(2, n + 1):
		ans *= i
		ans = ans % mod
	x = power(2, n - 1, mod)
	print((ans - x + mod) % mod)
solution()


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
n = r()
mod = 10 ** 9 + 7
ans1 = 1
ans2 = 1
for i in range(1, n):
	ans1 = ans1 * i % mod
	ans2 = ans2 * 2 % mod
ans1 *= n
print((ans1 - ans2) % mod)


N = int(input())
p = 10 ** 9 + 7
fact = [1, 1]
for i in range(2, N + 1):
	fact.append(fact[-1] * i % p)
ans = fact[N]
ans = (ans - pow(2, N - 1, p)) % p
print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
fact = 1
for i in range(2, n + 1):
	fact *= i
	if fact > mod:
		fact %= mod
two = 1
for i in range(1, n):
	two *= 2
	if two > mod:
		two %= mod
out((fact - two + mod) % mod)


n = int(input())
M = 10 ** 9 + 7
fact = [1] * (n + 2)
for i in range(2, n + 1):
	fact[i] = i * fact[i - 1] % M
print((fact[n] - pow(2, n - 1, M) + M) % M)


mod = 10 ** 9 + 7

def f(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	return ans
n = int(input())
good = pow(2, n - 1, mod)
ans = f(n) - good
if ans < 0:
	print(ans + mod)
else:
	print(f(n) - good)


import sys

def factorial(n):
	if n == 0:
		return 1
	ans = 1
	for k in range(1, n + 1):
		ans *= k
		ans %= pow(10, 9) + 7
	return ans
n = int(input())
x = factorial(n) - pow(2, n - 1, pow(10, 9) + 7)
if x < 0:
	x += pow(10, 9) + 7
print(x)


n = int(input())
m = 10 ** 9 + 7
r = 1
for i in range(1, n + 1):
	r = r * i % m
print((r - 2 ** (n - 1) % m) % m)


n = int(input())
mod = 10 ** 9 + 7
p = pow(2, n - 1, mod)
i = 0
s = 1
while i < n:
	s = s * (i + 1) % mod
	i = i + 1
ans = (s - p) % mod
print(ans)


def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
mod = 10 ** 9 + 7
x = int(input())
x1 = modFact(x, mod)
x2 = pow(2, x - 1, mod)
x3 = (x1 - x2) % mod
print(x3)


mod = 10 ** 9 + 7
base = 1
n = int(input())
sub = 2 ** (n - 1)
for i in range(2, n + 1):
	base = base * i % mod
print((base - sub + mod) % mod)


from math import ceil, floor
n = int(input())
i = 4
d = 4
c = 2
while i <= n:
	c = (c * i + d * (i - 2)) % (10 ** 9 + 7)
	d = d * 2 % (10 ** 9 + 7)
	i += 1
print(c % (10 ** 9 + 7))


import math
n = int(input().strip())
permutations = 1
for i in range(n):
	permutations = (i + 1) * permutations % (10 ** 9 + 7)
print((permutations - 2 ** (n - 1)) % (10 ** 9 + 7))


n = int(input())
mod = 1000000000 + 7
ans = 1
for i in range(2, n + 1):
	ans = ans * i % mod
ans = (ans - 2 ** (n - 1)) % mod
print(ans)


def modFact(n, p):
	ans = 1
	for i in range(2, n + 1):
		ans = i * (ans % p) % p
	return ans
n = int(input())
count = 0
m = 1
mod = 10 ** 9 + 7
aa = modFact(n - 1, mod)
for i in range(n - 1):
	count += (aa - m) % mod
	count %= mod
	m *= 2
	m %= mod
count += aa - 1
print(count % mod)


mod = 1000000007

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans % mod * (i % mod) % mod
	return ans
n = int(input())
f = fact(n)
e = 1
for i in range(1, n):
	e = e % mod * 2 % mod
f = (f - e) % mod
print(f)


mod = 10 ** 9 + 7
fact = [1] * (10 ** 6 + 1)
for i in range(2, 10 ** 6 + 1):
	fact[i] = i * fact[i - 1]
	fact[i] %= mod
for _ in range(1):
	n = int(input())
	print((fact[n] - pow(2, n - 1, mod)) % mod)


from math import *
n = int(input())
a = 1
b = 1
for i in range(1, n):
	b *= 2
	b %= 1000000007
	a *= i + 1
	a %= 1000000007
print(a - b + 1000000007 * (a - b < 0))


n = int(input())
if n < 3:
	print(0)
else:
	sol = 1
	neg = 1
	for i in range(1, n + 1):
		sol *= i
		sol %= 1000000007
	for i in range(n - 1):
		neg *= 2
		neg %= 1000000007
	sol -= neg
	if sol < 0:
		sol += 1000000007
	print(sol)


MOD = 10 ** 9 + 7

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans
n = int(input())
k = (1 << n - 1) % MOD
print((fact(n) - k) % MOD)


import math

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
ans = 0
left = n
mod = 10 ** 9 + 7
real = modFact(n, mod)
ans = 2 ** (n - 1) % mod
print((real - int(ans) + mod) % mod)


import math
INF = 10 ** 9 + 7
n = int(input())
res = 1
p = 1
for i in range(1, n + 1):
	res = res * i % INF
for i in range(1, n):
	p = p * 2 % INF
print((res - p) % INF)


n = int(input())
mod = 10 ** 9 + 7

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
t1 = modFact(n, mod)
t2 = pow(2, n - 1, mod)
ans = (t1 % mod - t2 % mod) % mod
print(ans)


M = 10 ** 9 + 7
n = int(input())

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % M
	return ans
total = fact(n)

def performMod(x, n, m):
	if n == 0:
		return 1 % m
	u = performMod(x, n // 2, m)
	u = u * u % m
	if n % 2 == 1:
		u = u * x % m
	return u
cnt = performMod(2, n - 1, M)
ans = (total - cnt + M) % M
print(ans)


m = 10 ** 9 + 7

def f(n):
	x = 1
	for i in range(1, n + 1):
		x = x % m * (i % m) % m
	return x % m
n = int(input())
r = f(n) - 2 ** (n - 1) % m
print(r % m)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
MOD = 1000000007
PMOD = 998244353
T = 1
for _ in range(T):
	n = int(stdin.readline())
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	print((ans - pow(2, n - 1, MOD)) % MOD)


mod = 10 ** 9 + 7

def factorial(n):
	f = 1
	for i in range(2, n + 1):
		f *= i
		f %= mod
	return f
n = int(input())
ans = factorial(n) - 2 ** (n - 1) % mod
if ans < 0:
	ans += mod
print(ans)


MOD = 1000000000.0 + 7

def power(n):
	res = 1
	while n > 0:
		res = res * 2 % MOD
		n -= 1
	return res

def fact(n):
	res = 1
	while n > 0:
		res = res * n % MOD
		n -= 1
	return res
n = int(input())
res = fact(n) - power(n - 1)
if res < 0:
	res += MOD
print(int(res))


mod = 10 ** 9 + 7

def fact(n):
	ans = n
	n -= 1
	while n > 1:
		ans = ans * n % mod
		n -= 1
	return (ans % mod - pow(2, t - 1, mod)) % mod
t = int(input())
h = fact(t)
print(h)


n = int(input())
m = 1000000007
fact = [1] * ((n >> 1) + 1)
for i in range(2, (n >> 1) + 1):
	fact[i] = fact[i - 1] * i % m
ans = 1
for i in range(1, n + 1):
	ans = ans * i % m
(p, b) = (1, 2)
n -= 1
while n:
	if n & 1:
		p = p * b % m
	b = b * b % m
	n >>= 1
ans = (m + ans - p) % m
print(ans)


from math import ceil
n = int(input())
first = 1
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	first *= i
	first %= mod
second = pow(2, n - 1, mod)
ans = ((first - second) % mod + mod) % mod
print(ans)


M = pow(10, 9) + 7

def fact(n):
	ans = 1
	if n <= M // 2:
		for i in range(1, n + 1):
			ans = ans * i % M
	else:
		for i in range(1, M - n):
			ans = ans * i % M
		ans = modinv(ans, M)
		if n % 2 == 0:
			ans = -1 * ans + M
	return ans % M
a = int(input())
ans = (fact(a) % M - (1 << a - 1) % M) % M
print(ans)


from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
import sys

def factorial(n):
	p = n
	fact = 1
	while n > 1:
		fact = fact * n % (10 ** 9 + 7)
		n -= 1
	res = 2 ** (p - 1) % (10 ** 9 + 7)
	return (fact - res) % (10 ** 9 + 7)
t = int(input())
print(factorial(t))


mod = pow(10, 9) + 7
fact = [1, 1]
for i in range(2, 10 ** 6):
	fact.append(fact[i - 1] * i % mod)
n = int(input())
d = {}
d[3] = 2
d[2] = 0
d[1] = 0
d[0] = 0
for i in range(4, n + 1):
	ans2 = (i - 2) * fact[i - 1] % mod
	ans2 += 2 * d[i - 1] % mod
	ans2 = ans2 % mod
	d[i] = ans2
print(d[n])


from functools import reduce
k = 1000000000.0 + 7
n = int(input())
print(int((reduce(lambda x, i: x * i % k, range(1, n + 1), 1) - reduce(lambda x, i: x * 2 % k, range(n - 1), 1)) % k))


n = int(input())
mo = 10 ** 9 + 7
f = [0] * (10 ** 6 + 1)
f[0] = 1
for i in range(1, len(f)):
	f[i] = f[i - 1] * i % mo

def C(u, v):
	return f[u] * pow(f[v], mo - 2, mo) % mo * pow(f[u - v], mo - 2, mo) % mo
print((f[n] - pow(2, n - 1, mo)) % mo)


n = int(input())
totalper = 1
inf = 1000000000.0 + 7
for i in range(n):
	totalper = totalper % inf * (i + 1) % inf % inf
totalper = totalper % inf
not_cyclic = pow(2, n - 1, int(inf))
not_cyclic = not_cyclic % inf
print(int(int(totalper - not_cyclic) % inf))


from sys import stdin
input = stdin.readline
n = int(input())
(res1, res2) = (1, 0)
mod = 1000000007
for x in range(2, n + 1):
	res1 = res1 * x % mod
res2 = pow(2, n - 1, mod)
print((res1 - res2) % mod)


n = int(input())
mod = 1000000000.0 + 7
a = 1
for i in range(1, n + 1):
	a = a * i
	a %= mod
a %= mod
b = 1
for i in range(n - 1):
	b *= 2
	b %= mod
b %= mod
ans = a - b + mod
ans %= mod
print(int(ans))


def fact(n):
	v = 1
	while n > 1:
		v *= n
		n -= 1
		v %= 10 ** 9 + 7
	return v
n = int(input())
f = fact(n)
u = 2 ** (n - 1)
print((f - u) % (10 ** 9 + 7))


Q = int(1000000000.0 + 7)

def factorial(n):
	global Q
	res = 1
	while n > 1:
		res = res * n % Q
		n -= 1
	return res
n = int(input())
print((factorial(n) - pow(2, n - 1, Q) + Q) % Q)


import math
f = math.factorial
n = int(input())
ans = 0
mod = int(1000000000.0) + 7
fac = 1
dif = 1
for i in range(2, n + 1):
	fac = fac * i % mod
for i in range(n - 1):
	dif = dif * 2 % mod
print((fac - dif) % mod)


n = int(input())
f = 1
m = pow(10, 9) + 7
p = 1
for i in range(2, n + 1):
	f = f * i % m
	p = p * 2 % m
print((f - p + m) % m)


import sys
from collections import defaultdict
import heapq
input = sys.stdin.readline
MOD = int(1000000000.0) + 7

def fast_pow(base, power, mod):
	if power == 1:
		return base
	val = fast_pow(base, power // 2, mod)
	if power % 2 == 0:
		return val * val % mod
	if power % 2 == 1:
		return val * val * base % mod

def fact_by_mod(n, mod):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
		ans %= mod
	return ans

def solve(n):
	return (fact_by_mod(n, MOD) - fast_pow(2, n - 1, MOD)) % MOD
n = int(input())
print(solve(n))


n = int(input())
MOD = 1000000007
ret1 = 1
ret2 = 1
for i in range(1, n + 1):
	ret1 = ret1 * i % MOD
for i in range(1, n):
	ret2 = ret2 * 2 % MOD
print((ret1 % MOD - ret2 % MOD + MOD) % MOD)


M = 1000000007
n = int(input())
fac = 1
for i in range(2, n + 1):
	fac *= i
	if fac >= M:
		fac %= M
print((fac - pow(2, n - 1, M) + M) % M)


MODULO = 10 ** 9 + 7

def num_of_cyclic_permutations(n):
	factorital = 1
	for i in range(2, n + 1):
		factorital = factorital * i % MODULO
	return (factorital - pow(2, n - 1, MODULO)) % MODULO

def main():
	n = int(input())
	print(num_of_cyclic_permutations(n))
main()


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
n = inn()
fact = 1
for i in range(1, n + 1):
	fact = fact * i % mo
res = (fact - 2 ** (n - 1)) % mo
print(res)


from math import factorial, gcd
from sys import stdin
input = stdin.readline
n = int(input())
f = 1
for i in range(1, n + 1):
	f = f * i % 1000000007
tp = pow(2, n - 1)
print((f - tp) % 1000000007)


import sys
input = sys.stdin.readline
n = int(input())
mod = 10 ** 9 + 7
ANS = 1
R = 0
for i in range(1, n + 1):
	ANS = ANS * i % mod
print((ANS - pow(2, n - 1, mod)) % mod)


n = int(input())
assert n >= 3
arr = [0] * (n + 1)
cnt = [0] * (n + 1)
arr[3] = 2
cnt[3] = 6
for i in range(4, n + 1):
	cnt[i] = cnt[i - 1] * i % (1000000000.0 + 7)
	arr[i] = (arr[i - 1] * i + (cnt[i - 1] - arr[i - 1]) * (i - 2)) % (1000000000.0 + 7)
print(int(arr[n] % (1000000000.0 + 7)))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def print_fract(p, q):
	g = math.gcd(p, q)
	p //= g
	q //= g
	print(str(p) + '/' + str(q))
p = 1000000007

def fn(n, modulus):
	ans0 = 1
	ans1 = 1
	for i in range(1, (n + 1) // 2):
		ans0 = ans0 * (2 * i + 0) % modulus
		ans1 = ans1 * (2 * i + 1) % modulus
	return ans0 * ans1 % modulus

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = inp()
a = fn(n, p)
if n % 2 == 0:
	a *= n
	a = a % p
print((a - power(2, n - 1, p)) % p)


n = int(input())
mod = 10 ** 9 + 7
res = 1
rem = 1
for i in range(2, n + 1):
	res = res * i % mod
	rem = rem * 2 % mod
ans = (res - rem + mod) % mod
print(ans)


import math
n = int(input())
b = 10 ** 9 + 7
f = 1
for i in range(1, n + 1):
	f = f * i % b
print((f % b - (1 << n - 1) % b) % b)


n = int(input())
MOD = int(1000000000.0) + 7
f = [0] * (n + 2)
g = [0] * (n + 2)
f[0] = 1
g[0] = g[1] = 1
for i in range(1, n + 1):
	f[i] = f[i - 1] * i % MOD
	if i >= 2:
		g[i] = g[i - 1] * 2 % MOD
print((f[n] - g[n]) % MOD)


def fact(n, p):
	if n < 2:
		return 1
	else:
		res = 1
		while n:
			res = res % p * (n % p) % p
			n = (n % p - 1) % p
	return res

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(input())
p = pow(10, 9) + 7
out = (fact(n, p) % p - power(2, n - 1, p) % p) % p
print(out)


import math
n = int(input())
i = 1
fact = 1
while i <= n:
	fact *= i
	fact %= 1000000007
	i += 1
print((fact - 2 ** (n - 1) % 1000000007) % 1000000007)


import sys
input = sys.stdin.readline
N = int(input())
MOD = 10 ** 9 + 7
start = 1
to_remove = 1
for i in range(1, N + 1):
	start = start * i % MOD
	if i > 1:
		to_remove = to_remove * 2 % MOD
res = (start - to_remove) % MOD
print(res)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def pw(a, b, md):
	result = 1
	while b > 0:
		if b % 2 == 1:
			result *= a
			result %= md
		a *= a
		a %= md
		b //= 2
	return result % md

def inpt():
	return [int(k) for k in input().split()]

def main():
	n = int(input())
	ans = 1
	md = 10 ** 9 + 7
	for i in range(n, 0, -1):
		ans *= i
		ans %= md
	p = pw(2, n - 1, md)
	res = (ans - p) % md
	print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
ans = 1
d = 1
mr = 10 ** 9 + 7
for i in range(1, n + 1):
	ans = ans * i % mr
d = pow(2, n - 1, mr)
print((ans - d) % mr)


n = int(input())
a = 1
b = 2 ** (n - 1) % (10 ** 9 + 7)
for i in range(2, n + 1):
	a = a * i % (10 ** 9 + 7)
print((a - b) % (10 ** 9 + 7))


t = 1
num = pow(10, 9) + 7
for _ in range(t):
	n = int(input())
	fcn = 1
	for i in range(2, n + 1):
		fcn = i * fcn % num
	y = n - 1
	x = 2
	x = x % num
	if x == 0:
		pow_val = 0
	else:
		pow_val = 1
		while y > 0:
			if y & 1 == 1:
				pow_val = pow_val * x % num
			y = y >> 1
			x = x * x % num
	ans = (fcn - pow_val) % num
	print(ans)


a = int(input())
d = 2
ad = 4
for i in range(3, a):
	d = d * (i + 1)
	d += ad * (i - 1)
	ad = ad * 2
	d %= 10 ** 9 + 7
	ad %= 10 ** 9 + 7
print(d % (10 ** 9 + 7))


import sys
import math
input = sys.stdin.readline
mod = 1000000007

def adjorial():
	adj = [0] * 1000003
	adj[0] = 1
	adj[1] = 1
	for i in range(2, 1000001):
		adj[i] = adj[i - 1] * i % mod
	return adj

def solve(n):
	l = adjorial()
	result = l[n]
	result = result - pow(2, n - 1, mod)
	print(result % mod)
n = int(input())
if n == 1 or n == 2:
	print(0)
solve(n)


import sys
input = sys.stdin.readline

def main():
	MOD = 10 ** 9 + 7
	N = int(input())
	fact = [1, 1]
	for i in range(2, N + 1):
		fact.append(fact[-1] * i % MOD)
	print((fact[N] - pow(2, N - 1, MOD)) % MOD)
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	n = N()
	p = 1
	for i in range(2, n + 1):
		p *= i
		p %= mod
	t = pow(2, n - 1, mod)
	t = (p - t) % mod
	print((t + mod) % mod)
solve()


import math
n = int(input())
if n == 3:
	print(2)
else:
	a = 1
	b = 1
	for i in range(1, n + 1):
		a = a * i % (10 ** 9 + 7)
	b = pow(2, n - 1, 1000000007)
	c = (a - b) % (10 ** 9 + 7)
	print(c)


n = int(input())
mod = int(1000000000.0 + 7)

def fact(n):
	f = 1
	for i in range(n):
		f = f * (i + 1)
		f = f % mod
	return f % mod
p = fact(n) - pow(2, n - 1, mod) + mod
p = p % mod
print(int(p))


def fac(n):
	res = 1
	for i in range(1, n + 1):
		res = res * i % 1000000007
	return res
n = int(input())
print((fac(n) - 2 ** (n - 1)) % 1000000007)


n = int(input())
mod = 10 ** 9 + 7
fact = 1
twos = 1
for i in range(1, n + 1):
	fact = i * fact
	fact = fact % mod
	if i != 1:
		twos *= 2
		twos = twos % mod
print((fact - twos) % mod)


n = int(input())
md = 10 ** 9 + 7
result = 1
for i in range(1, n + 1):
	result = result * i % md
mn = pow(2, n - 1, md)
ans = (result - mn) % md
print(ans)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict
n = ri()
f = [1]
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	f.append(f[-1] * i % mod)
x = pow(2, n - 1, mod)
wi((f[-1] - x) % mod)


n = int(input())
rem = 1000000007
a1 = 1
for i in range(1, n + 1):
	a1 = a1 * i % rem % rem
ans = (a1 - pow(2, n - 1, rem)) % rem
print(ans)


from functools import lru_cache
from sys import stdin, stdout
import sys

def noOfPermutations(a, n, mod):
	if n == 1:
		return 1
	a.sort()
	if a[n - 1] == a[n - 2]:
		return 0
	x = 0
	for i in range(n - 2):
		if a[i] == a[i + 1]:
			if a[i] == a[i + 2]:
				return 0
			x += 1
			i += 1
	return pow(2, n - 2 * x - 1, mod)
n = int(input())
a = [i + 1 for i in range(n)]
mod = 1000000007
num = noOfPermutations(a, n, mod)
f = 1
for i in range(2, n + 1):
	f = f * i % mod
print((f - num) % mod)


def fact(n):
	sol = 2
	M = 1000000007
	for i in range(3, n + 1):
		sol *= i
		sol %= M
	return sol % M
n = int(input())
M = 1000000007
print((fact(n) - (1 << n - 1) % M) % M)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def modInverse(a, p):
	return power(a, p - 2, p)

def modFact(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * modInverse(i, p) % p
	return res

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True
m = 10 ** 9 + 7

def my_fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans % m * i % m % m
	return ans

def main():
	n = int(input())
	ans = (my_fact(n) % m - pow(2, n - 1, m) % m + m) % m
	print(ans)
TestCases = False
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import math

def mi():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return input().split()
n = ii()
mod = 10 ** 9 + 7
fact = 1
for i in range(1, n + 1):
	fact *= i
	fact %= mod
sub = 1
for i in range(1, n):
	sub *= 2
	sub %= mod
ans = fact - sub
print(ans % mod)


n = int(input())
mod = int(1000000000.0 + 7)
fact = 1
for i in range(1, n + 1):
	fact *= i
	fact %= mod
print((fact - 2 ** (n - 1) + mod) % mod)


M = 10 ** 9 + 7
n = int(input())
factorial = 1
for i in range(1, n + 1):
	factorial = factorial * i % M
result = (factorial - pow(2, n - 1)) % M
print(result)


from math import *
m = 10 ** 9 + 7
n = int(input())
f = 1
for i in range(1, n + 1):
	f = f * i
	f = f % m

def bn(a, b):
	x = 1
	b = bin(b)
	b = b[2:]
	b = list(b)
	b.reverse()
	i = 0
	while i < len(b):
		if b[i] == '1':
			x = x * a
			x = x % m
		a = a * a
		a = a % m
		i = i + 1
	return x
p = bn(2, n - 1)
ans = (f - p) % m
print(ans % m)


n = int(input())
N = 1000000007
nfact = 1
for i in range(1, n + 1):
	nfact = nfact * i
	nfact = nfact % N
npower = 1
for i in range(1, n):
	npower = npower * 2
	npower = npower % N
print((nfact - npower) % N)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007
n = int(input())
factor = 1
for i in range(2, n + 1):
	factor = factor * i % mod
power2 = 1
for i in range(1, n):
	power2 = power2 * 2 % mod
answer = factor - power2
if answer < 0:
	answer += mod
print(answer)


n = int(input())
ans1 = 1
ans2 = 1
for i in range(1, n + 1, 1):
	ans1 = ans1 * i
	ans1 %= 1000000007
for i in range(1, n, 1):
	ans2 = ans2 * 2
	ans2 %= 1000000007
print((ans1 - ans2) % 1000000007)


from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	ans = 1
	for i in range(1, N + 1):
		ans *= i
		ans %= con
	val = pow(2, N - 1, con)
	ans = (ans - val) % con
	print(ans)
main()


n = int(input())
mod = int(10 ** 9 + 7)
fact = 1
step = 1
for i in range(1, n + 1):
	fact = fact * i % mod
for i in range(n - 1):
	step = step * 2 % mod
print((fact - step) % mod)


n = int(input())
M = int(1000000000.0 + 7)
fac = [1]
for i in range(1, int(1000000.0 + 1)):
	fac.append(fac[-1] * i % M)
print((fac[n] - pow(2, n - 1, M)) % M)


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
(n,) = gil()
f = 1
p = 1
for i in range(2, n + 1):
	f = f * i % mod
	p = p * 2 % mod
print((f - p + mod) % mod)


import sys
import math
from math import factorial, inf, gcd
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 5)
mod = 10 ** 9 + 7
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
print((ans - pow(2, n - 1, mod) + mod) % mod)


n = int(input())
nfac = 1
twop = 1
for i in range(2, n + 1):
	nfac = nfac * i % 1000000007
	twop = twop * 2 % 1000000007
ans = (nfac - twop) % 1000000007
print(ans)


n = int(input())
ans = 1
an = 1
for j in range(2, n + 1):
	ans = ans * j % 1000000007
	an = (an << 1) % 1000000007
ans -= an
print(ans % 1000000007)


n = int(input())
MOD = 10 ** 9 + 7
nc = 1
tot = 1
for i in range(2, n + 1):
	tot = tot * i % MOD
	nc = nc * 2 % MOD
print((tot - nc) % MOD)


def fact(n):
	res = 1
	for i in range(1, n + 1):
		res *= i
		res %= 1000000007
	return res
n = int(input())
ans = fact(n)
subtract = 1
for i in range(0, n - 1):
	subtract *= 2
	subtract %= 1000000007
ans -= subtract
ans %= 1000000007
print(ans)


from collections import *
from random import *
from decimal import Decimal
from heapq import *
from bisect import *
import sys
from itertools import *
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def st1():
	return input().rstrip('\n')
t = 1
while t:
	t -= 1
	n = inp()
	x = 1
	p = 1000000007
	for i in range(1, n + 1):
		x = x * i
		x = x % p
	y = pow(2, n - 1, p)
	print((x - y) % p)


mod = 10 ** 9 + 7
fac = [1]
for i in range(1, 10 ** 6 + 1):
	fac.append(fac[-1] * i % mod)

def main():
	n = int(input())
	print((fac[n] - pow(2, n - 1, mod)) % mod)
main()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def powmod(a, b, m):
	a %= mod
	res = 1
	while b:
		if b & 1:
			res *= a
			res %= mod
		a *= a
		a %= mod
		b >>= 1
	return res

def solve():
	n = ii()
	ans = 6
	for i in range(4, n + 1):
		ans *= i
		ans %= mod
	ans -= powmod(2, n - 1, mod)
	ans += mod
	ans %= mod
	print(ans)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		t = 1
		for i in range(1, n + 1):
			t *= i
			t %= mod
		rr.append((t - pow(2, n - 1, mod)) % mod)
	return JA(rr, '\n')
print(main())


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	n = II()
	if n == 3:
		P(2)
		return
	(pp, npp) = (2, 4)
	fct = 6
	for i in range(4, n + 1):
		fct = fct * i % mod
		curr_ans = (pp * i + npp * (i - 2)) % mod
		pp = curr_ans
		npp = fct - curr_ans
	P(curr_ans)
	return
t = 1
for i in range(t):
	solve()


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())
sys.setrecursionlimit(1500)

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		ans = 1
		for x in range(1, n + 1):
			ans = ans % P * (x % P) % P
		temp = 2
		for x in range(n - 2):
			temp = temp % P * (2 % P) % P
		print((ans % P - temp % P) % P)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


n = int(input())
R = lambda : map(int, input().split())
answers = []
c = 1
div = 1000000000 + 7
for i in range(1, n + 1):
	c *= i
	c = c % div
ans = c - pow(2, n - 1, div)
if ans < 0:
	print(ans + div)
else:
	print(ans)


n = int(input())
MOD = 10 ** 9 + 7
nc = pow(2, n - 1, MOD)
fact = 1
for i in range(1, n + 1):
	fact *= i
	if fact > MOD:
		fact %= MOD
res = (fact - nc) % MOD
print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class union_find:

	def __init__(self, n):
		self.n = n
		self.rank = [0] * n
		self.parent = [int(j) for j in range(n)]

	def union(self, i, j):
		i = self.find(i)
		j = self.find(j)
		if self.rank[i] == self.rank[j]:
			self.parent[i] = j
			self.rank[j] += 1
		elif self.rank[i] > self.rank[j]:
			self.parent[j] = i
		else:
			self.parent[i] = j

	def find(self, i):
		temp = i
		if self.parent[temp] != temp:
			self.parent[temp] = self.find(self.parent[temp])
		return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC

def main():
	MOD = int(1000000000.0 + 7)
	n = int(input())
	fac = 1
	for i in range(n):
		fac = fac * (i + 1)
		fac = fac % MOD
	fac = fac - pow(2, n - 1, MOD)
	if fac < 0:
		fac += MOD
	print(int(fac))
main()


MOD = 10 ** 9 + 7

def fact(N):
	result = 1
	while N:
		result *= N
		result %= MOD
		N -= 1
	return result % MOD

def solve(N):
	if N <= 2:
		return 0
	return (fact(N) - 2 ** (N - 1)) % MOD

def main():
	N = int(input())
	ans = solve(N)
	print(ans)
main()


import math
import sys
import itertools
import random
import bisect
import heapq
import collections

def lcm(x, y):
	return x * y // math.gcd(x, y)

def hcf(x, y):
	return math.gcd(x, y)

def primes(n):
	prime = [True for _ in range(0, n + 1)]
	res = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[p] = False
		p += 1
	for i in range(0, n + 1):
		if prime[i] == True:
			res.append(i)
	return res

def primeFactors(n):
	res = []
	while n % 2 == 0:
		res.append(2)
		n //= 2
	for i in range(3, math.sqrt(n) + 1, 2):
		while n % i == 0:
			res.append(i)
			n //= i
	if n > 2:
		res.append(n)
	return res

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
print((modFact(n, 10 ** 9 + 7) - power(2, n - 1, 10 ** 9 + 7)) % (10 ** 9 + 7))


n = int(input())
c = 1
p = n
MOD = 1000000007
for i in range(1, n):
	p = p * i % MOD
	c = c * 2 % MOD
ans = (p - c + MOD) % MOD
print(ans)


t = int(input())
ans = 2
p = 1000000007
f3 = 24
f2 = 6
for i in range(4, t + 1):
	ans = f3 - 2 * (f2 - ans) % p
	ans %= p
	f2 = f3
	f3 = f3 * (i + 1) % p
print(ans % p)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
letters = ascii_letters[:26]
n = int(input())
res = 1
for i in range(1, n + 1):
	res = res * i % 1000000007
res = (res - 2 ** (n - 1)) % 1000000007
print(res)


n = int(input())
mod = 10 ** 9 + 7
fac = [1, 1]
for i in range(2, n + 1):
	fac.append(fac[i - 1] * i % mod)

def power(x):
	if x == 0:
		return 1
	else:
		res = power(x // 2)
		res = res ** 2 % mod
		if x % 2 != 0:
			res = res * 2 % mod
		return res
print((fac[n] - power(n - 1)) % mod)


mod = 10 ** 9 + 7
n = int(input())
fa = [1] * (n + 1)
fi = [1] * (n + 1)
for i in range(1, n + 1):
	fa[i] = fa[i - 1] * i % mod
ans = 0
print((fa[n] - pow(2, n - 1, mod)) % mod)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 10 ** 9 + 7
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	n = N()
	res = 1
	for i in range(2, n + 1):
		res = res * i % mod
	print((res - pow(2, n - 1, mod)) % mod)
main()


mod = 10 ** 9 + 7
n = int(input())
res = 1
ans = 1
for item in range(1, n):
	res *= item
	res = res % mod
	ans *= 2
	ans = ans % mod
res *= n
res -= ans
print(res % mod)


n = int(input())
x = 1000000007
ans = 1
p = 0.5
for i in range(1, n + 1):
	ans = ans * i % x
	p = p * 2 % x
print(int(ans - p) % x)


MOD = 1000000007

def powr(n, N):
	temp = 1
	while N > 0:
		if N % 2 != 0:
			temp = temp * n % MOD
		n = n * n % MOD
		N = N // 2
	return temp % MOD
n = int(input())
tt1 = 1
for i in range(1, n + 1):
	tt1 = tt1 * i % MOD
tt2 = powr(2, n - 1) % MOD
ans = (tt1 - tt2) % MOD
print(ans)


import math
n = int(input())
mod = 10 ** 9 + 7
x = 2
for i in range(3, n + 1):
	x *= i
	x %= mod
print((x - 2 ** (n - 1)) % mod)


n = int(input())
m = int(1000000000.0 + 7)
f = 1
for i in range(2, n + 1):
	f = f * i % m
print((f - pow(2, n - 1, m) + m) % m)


import sys
input = sys.stdin.readline
n = int(input())
mod = 1000000000 + 7

def fac(n, modulus):
	ans = 1
	if n <= modulus // 2:
		for i in range(1, n + 1):
			ans = ans * i % modulus
	else:
		for i in range(n + 1, modulus):
			ans = ans * i % modulus
		ans = modinv(ans, modulus)
		ans = -1 * ans + modulus
	return ans % modulus
a = 1
for i in range(1, n):
	a = a * 2 % mod
print((fac(n, mod) - a) % mod)


n = int(input())
a = 4
for i in range(3, n):
	a *= 2
	a = a % (10 ** 9 + 7)
x = 1
for i in range(1, n + 1):
	x *= i
	x = x % (10 ** 9 + 7)
print((x - a) % (10 ** 9 + 7))


def fact(n):
	answ = 1
	for i in range(1, n + 1):
		answ *= i
		answ %= 10 ** 9 + 7
	return answ
n = int(input())
answ = fact(n) - pow(2, n - 1, 10 ** 9 + 7)
print(answ % (10 ** 9 + 7))


def resolve():
	N = int(input())
	base = 10 ** 9 + 7
	mod_1 = 2
	for i in range(3, N + 1):
		mod_1 *= i
		if mod_1 > base:
			mod_1 = mod_1 % base
	mod_2 = pow(2, N - 2, base)
	result = (mod_1 - 2 * mod_2) % base
	print(result)
resolve()


n = int(input())
(start, mod) = (1, 1000000007)
for i in range(n, 0, -1):
	start = start * i % mod
start = (start - 2 ** (n - 1)) % mod
print(start)


from sys import stdin
from collections import defaultdict
import itertools
import math

def rei():
	return list(map(int, stdin.readline().strip().split(' ')))

def res():
	return stdin.readline().rstrip()

def prno():
	print('NO')

def pryes():
	print('YES')

def solve():
	n = rei()[0]
	ans = 1
	mod = 10 ** 9 + 7
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	ans %= mod
	ans -= 2 ** (n - 1) % mod
	ans %= mod
	print(ans)
solve()


def fact_mod(i, mod):
	ret = 1
	for j in range(2, i + 1):
		ret *= j
		ret %= mod
	return ret

def pow2mod(i, mod):
	ret = 1
	for j in range(i):
		ret *= 2
		ret %= mod
	return ret

def sol(i):
	return (fact_mod(i, 1000000007) - pow2mod(i - 1, 1000000007)) % 1000000007
n = int(input())
print(sol(n))


fact = [1]
e = 10 ** 9 + 7
for i in range(1, 10 ** 6 + 1):
	x = i * fact[-1] % e
	fact.append(x)
n = int(input())
ans = pow(2, n - 1, e)
ans = (fact[n] - ans) % e
print(ans)


MOD = 10 ** 9 + 7

def powmod(a, b, m):
	a %= MOD
	res = 1
	while b:
		if b & 1:
			res *= a
			res %= MOD
		a *= a
		a %= MOD
		b >>= 1
	return res
ans = 1
n = int(input())
for i in range(n):
	ans *= i + 1
	ans %= MOD
ans -= powmod(2, n - 1, MOD)
print(ans % MOD)


import math
mod = 10 ** 9 + 7
t = int(input())
f = 1
for i in range(1, t + 1):
	f = f * i % mod
ans = 2 ** (t - 1) % mod
print(int((f - int(ans)) % mod))


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
md = 10 ** 9 + 7
an = 4
k = 3
ft = 6
while k < n:
	k += 1
	ft = ft * k % md
	an = an * 2 % md
print((ft - an) % md)


a = int(input())

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
ans = modFact(a, pow(10, 9) + 7) - pow(2, a - 1, pow(10, 9) + 7)
if ans < 0:
	ans = pow(10, 9) + 7 - abs(ans)
print(ans)


n = int(input())
potega = 1
for x in range(2, n + 1):
	potega *= x
	potega %= 10 ** 9 + 7
print((potega - 2 ** (n - 1)) % (10 ** 9 + 7))


def main():
	n = int(input())
	ans = 1

	def cmb(n, r, mod):
		if r < 0 or r > n:
			return 0
		r = min(r, n - r)
		return g1[n] * g2[r] * g2[n - r] % mod
	mod = 10 ** 9 + 7
	N = n
	inv_t = [0] + [1]
	for i in range(2, N):
		inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	ans -= 1
	tmp = 1
	for i in range(1, n):
		tmp *= n - i
		tmp *= inv_t[i]
		tmp %= mod
		ans -= tmp
	print(ans % mod)
main()


import sys
MOD = 10 ** 9 + 7
fact = [1] * 1000001
N = int(input())
for i in range(2, N + 1):
	fact[i] = fact[i - 1] * i % MOD
print((fact[N] - 2 ** (N - 1)) % MOD)


MOD = 10 ** 9 + 7
n = int(input())
fac = 1
for i in range(1, n + 1):
	fac = fac * i % MOD
pw = 1
for i in range(n - 1):
	pw = pw * 2 % MOD
print((fac - pw + MOD) % MOD)


from sys import stdin
input = stdin.readline
mod = 10 ** 9 + 7
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
print((ans - pow(2, n - 1, mod)) % mod)


N = int(input())
mod = 10 ** 9 + 7
fac = 1
for i in range(2, N + 1):
	fac = fac * i % mod
ans = (fac - pow(2, N - 1, mod)) % mod
print(ans)


def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
i = int(input())
p = int(1000000000.0 + 7)
d = pow(2, i - 1) % p
j = modFact(i, p)
print((j - d) % p)


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict
MOD = 1000000007

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def to_zero(n, s):
	lst = s[0]
	ans = []
	for i in range(n):
		if lst == s[i]:
			continue
		elif lst == '0':
			lst = '1'
			ans.append(i)
		else:
			lst = '0'
			ans.append(i)
	if lst == '1':
		ans.append(n)
	return ans
n = int(input())
r = 1
for i in range(1, n + 1):
	r *= i
	r %= MOD
l = 1
for i in range(1, n):
	l *= 2
	l %= MOD
r -= l
print(r % MOD)


n = int(input())
f = 1
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	f = f * i % mod
c = pow(2, n - 1, mod)
ans = (f - c) % mod
print(ans)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	mod = 10 ** 9 + 7
	factorial = [1, 1]
	n = int(input())
	for i in range(2, n + 1):
		factorial.append(factorial[-1] * i % mod)
	ans = factorial[n] - power(2, n - 1, mod)
	print(ans % mod)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
md = 10 ** 9 + 7
mx = 10 ** 6 + 5
fac = [1]
for i in range(1, mx + 1):
	fac.append(fac[-1] * i % md)
n = II()
ans = fac[n] - pow(2, n - 1, md)
print(ans % md)


mod = 10 ** 9 + 7

def func(i):
	if i == 0:
		return 1
	return fact[n - 1] * pow(fact[i] * fact[n - 1 - i], mod - 2, mod) % mod % mod

def calc():
	return pow(2, n - 1, mod)
n = int(input())
fact = [1, 1]
for i in range(2, n + 1):
	fact.append(fact[-1] * i % mod)
ans = fact[n]
print((ans - calc()) % mod)


from math import factorial
n = int(input())
count = 1
s = 1
for i in range(1, n + 1):
	count = count * i % (10 ** 9 + 7)
for i in range(n - 1):
	s = s * 2 % (10 ** 9 + 7)
print((count - s) % (10 ** 9 + 7))


MOD = 10 ** 9 + 7
MAX = 10 ** 6 + 1
fact = [i for i in range(MAX)]
fact[0] = 1
for i in range(1, MAX):
	fact[i] = fact[i] * fact[i - 1] % MOD

def ncr(n, r):
	return fact[n] * pow(fact[r] * fact[n - r] % MOD, MOD - 2, MOD) % MOD
for tc in range(1):
	N = int(input())
	ans = pow(2, N - 1, MOD)
	print((fact[N] - ans) % MOD)


from math import factorial
p = 10 ** 9 + 7
f = [1, 1, 2]
for i in range(3, 10 ** 6 + 1):
	f.append(f[-1] % p * (i % p) % p)

def main():
	n = int(input())
	x = f[n] - pow(2, n - 1, p)
	if x < 0:
		x += p
	print(x)
main()


m = 1000000007
n = int(input())
p = 1
s = 1
for i in range(1, n + 1):
	s = s * i % m
	if i < n:
		p = p * 2 % m
print((s % m - p % m) % m)


def gns():
	return list(map(int, input().split()))
n = int(input())
a = 1
t = 1
m = 10 ** 9 + 7
for i in range(2, n + 1):
	t = t * i % m
	a = a * 2 % m
if t < a:
	t += m
print(t - a)


import sys
import random
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return map(int, tinput())

def fiinput():
	return map(float, tinput())

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	n = iinput()
	(res, ans, mod) = (1, 1, int(1000000000.0 + 7))
	for i in range(1, n + 1):
		res = res * i % mod
	for i in range(1, n):
		ans = ans * 2 % mod
	print((res - ans + mod) % mod)
for inytd in range(1):
	main()


import sys

def fact(n, MOD):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % MOD
	return ans % MOD
MOD = 1000000007
n = int(input())
a = pow(2, n - 1, MOD)
b = fact(n, MOD)
print((b - a) % MOD)


MOD = 10 ** 9 + 7

def pm(a, n):
	if n == 0:
		return 1
	t = pm(a, n // 2)
	t = t * t % MOD
	if n % 2 == 1:
		t = t * a % MOD
	return t

def fac(n):
	t = 1
	for i in range(2, n + 1):
		t = t * i % MOD
	return t
n = int(input())
res = (fac(n) - pow(2, n - 1)) % MOD
if res < 0:
	res += MOD
print(res)


from math import factorial as fa
n = int(input())
f = [1]
m = 10 ** 9 + 7
mx = 10 ** 6 + 5
for i in range(1, mx + 1):
	f.append(f[-1] * i % m)
r = f[n] - pow(2, n - 1, m)
print(r % m)


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))
mod = 10 ** 9 + 7
fac = [1, 1, 2, 6]
for i in range(4, 10 ** 6 + 1):
	new_fac = fac[i - 1] * i % mod
	fac.append(new_fac)
n = nn()
print((fac[n] - 2 ** (n - 1)) % mod)


def main():
	mod = int(1000000000.0) + 7
	n = int(input())
	t = 1
	for i in range(1, n + 1):
		t = t * i % mod
	u = 1
	for i in range(n - 1):
		u = 2 * u % mod
	print((mod + t - u) % mod)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def factorial(n):
	M = 1000000007
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f
n = int(input())
z = int(1000000000.0 + 7)
d = pow(2, n - 1) % z
print((factorial(n) - d) % z)


t = 1
mod = 1000000007

def fac(n):
	p = 1
	for i in range(2, n + 1):
		p = p * i % mod
	return p
for _ in range(t):
	n = int(input())
	s = 1
	for i in range(n - 1):
		s = s * 2 % mod
	print((fac(n) - s) % mod)


x = int(input())
fact = 1
for i in range(2, x + 1):
	fact = i * fact % (10 ** 9 + 7)
pow2 = 1
for i in range(x - 1):
	pow2 = pow2 * 2 % (10 ** 9 + 7)
print((fact - pow2) % (10 ** 9 + 7))


import math
M = 10 ** 9 + +7

def fact(x):
	ans = 1
	for i in range(2, x + 1):
		ans = ans * i % M
	return ans

def modpow(b, p):
	res = 1
	while p:
		if p % 2:
			res = res * b % M
		p >>= 1
		b = b * b % M
	return res

def tc():
	n = int(input())
	f = fact(n)
	ans = (f - modpow(2, n - 1)) % M
	print(ans)
tc()


M = 10 ** 9 + 7

def fact(n):
	if n >= M:
		return 0
	m = 1
	for i in range(1, n + 1):
		m = m * i % M
	return m
n = int(input())
k = fact(n) % M
j = pow(2, n - 1, M)
print((k % M - j % M) % M)


from sys import stdin
ip = stdin.readline
n = int(ip())
m = int(1000000000.0) + 7
f = 1
a = 1
for i in range(2, n + 1):
	f = f * i % m
	a = a * 2 % m
print((f - a + m) % m)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
n = int(input())
ans = 1
for i in range(2, n + 1):
	ans = ans * i % MOD
sub = 2
for i in range(2, n):
	sub = sub * 2 % MOD
ans = ans - sub
if ans < 0:
	ans += MOD
print(ans)


n = int(input())
mod = 10 ** 9 + 7
fact = 1
for i in range(1, n + 1):
	fact *= i
	fact %= mod
ans = fact - (1 << n - 1)
print(ans % mod)


def factorial(n, mod):
	res = 1
	for i in range(1, n + 1):
		res *= i
		res %= mod
	return res
n = int(input())
mod = 1000000007
print((factorial(n, mod) - pow(2, n - 1, mod)) % mod)


n = int(input())
m = 1000000007
ans = 1
ans1 = 1
for i in range(n):
	ans = ans * (i + 1) % m
for i in range(n - 1):
	ans1 = ans1 * 2 % m
print((ans - ans1) % m)


def factorial_mod(n, m):
	fact = 1
	for i in range(1, n + 1):
		fact = fact * i % m
	return fact

def power_mod(n, p, m):
	pow = 1
	for i in range(1, p + 1):
		pow = pow * n % m
	return pow
n = int(input())
answer = factorial_mod(n, 10 ** 9 + 7) - power_mod(2, n - 1, 10 ** 9 + 7)
answer = answer % (10 ** 9 + 7)
print(answer)


n = int(input())
fact = 1
po = 1
modd = 1000000007
for i in range(2, n + 1):
	fact = fact * i % modd
	po = po * 2 % modd
print((modd + fact - po) % modd)


import os
from collections import defaultdict, deque
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins():
	return list(map(int, input_().split(' ')))

def inss():
	return list(input_().split(' '))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def ranin():
	return range(int(input_()))

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)
k = 1000000000.0 + 7
n = int(input_())
x = 1
for i in range(1, n + 1):
	x *= i
	x = int(x % k)
j = 1
for i in range(n - 1):
	j *= 2
	j %= k
if x <= j:
	print_(int(k + x - j))
else:
	print_(int(x - j))
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()


mod = 10 ** 9 + 7

def solve():
	n = int(input())
	ans = 0
	p = 1
	for i in range(2, n):
		p = p * i % mod
		ans = (ans * 2 + p * (i - 1)) % mod
	print(ans)
t = 1
for _ in range(t):
	solve()


MOD = 1000000007
n = int(input())
k = 1
L = []
for i in range(2, n + 1):
	k *= i
	k %= MOD
	L.append(k)
k2 = 1
for i in range(n - 1):
	k2 *= 2
	k2 %= MOD
print((k - k2 + MOD * MOD) % MOD)


m = 10 ** 9 + 7

def fac(n):
	f = 1
	for i in range(n):
		f = f * (i + 1) % m
	return f

def two(n):
	t = 1
	for i in range(n):
		t = t * 2 % m
	return t
n = int(input())
f = fac(n)
t = two(n - 1)
r = f - t
if r < 0:
	r = r + m
print(r)


MOD = 10 ** 9 + 7
n = int(input())
ret1 = 1
for i in range(1, n + 1):
	ret1 = ret1 * i % MOD
ret2 = 1
for i in range(1, n):
	ret2 = ret2 * 2 % MOD
ans = (ret1 - ret2 + MOD) % MOD
print(ans)


def main():
	import sys
	input = sys.stdin.readline
	MOD = 10 ** 9 + 7
	n = int(input())
	ans = 0
	fact = [1] * (n + 1)
	invfact = [1] * (n + 1)
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % MOD
	invfact[-1] = pow(fact[-1], MOD - 2, MOD)
	for i in range(n, 0, -1):
		invfact[i - 1] = invfact[i] * i % MOD

	def nCr(n, r):
		if r == 0 or r == n:
			return 1
		r = min(r, n - r)
		return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD
	ans = fact[n]
	for i in range(n):
		ans = (ans - nCr(n - 1, i)) % MOD
	print(ans)
main()


n = int(input())
t = 1
for i in range(2, n + 1):
	t *= i
	t %= 1000000007
t2 = pow(2, n - 1, 1000000007)
t = (t - t2 + 1000000007) % 1000000007
print(t)


def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
a = rn()
M = int(1000000000.0 + 7)
tot = 1
for i in range(2, a + 1):
	tot = tot * i % M
x = pow(2, a - 1, M)
print((tot - x) % M)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
n = N()
M = 1000000007
now = 6
for i in range(4, n + 1):
	now *= i
	now %= M
now = now + M
r = 1
for _ in range(n - 1):
	r <<= 1
	r %= M
print((now - r) % M)


import sys
mod = 1000000007
num = int(input())
sub = 1
for x in range(1, num):
	sub *= 2
	if sub > mod:
		sub = sub % mod
ans = 1
for x in range(2, num + 1):
	ans *= x
	ans = ans % mod
print((ans - sub) % mod)


import sys
input = sys.stdin.readline
n = int(input())
div = 10 ** 9 + 7
ans = 1
for i in range(1, n + 1):
	ans *= i
	ans = ans % div
kans = 1
for i in range(1, n):
	kans *= 2
	kans = kans % div
print((ans - kans) % div)


import sys, math
try:
	(sys.stdin, sys.stdout) = (open('input.txt', 'r'), open('out.txt', 'w'))
except:
	pass
from sys import stdin, stdout
mod = int(1000000000.0 + 7)
from statistics import mode
from collections import *
from math import ceil, floor, inf, factorial, gcd, log2, sqrt, log
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()

def lcm(a, b):
	return a * b // gcd(a, b)

def setbits(n):
	return bin(n).count('1')

def resetbits(n):
	return bin(n).count('0')

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r):
	(num, den) = (1, 1)
	r = min(n, n - r)
	for i in range(r):
		num *= n - i
		den *= i + 1
	return num // den

def ncr_p(n, r, p):
	(num, den) = (1, 1)
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modinv(den, p) % p

def isPrime(num):
	if num <= 1:
		return False
	if num == 2 or n == 3:
		return True
	if num % 2 == 0 or num % 3 == 0:
		return False
	m = int(num ** 0.5) + 1
	for i in range(5, m, 6):
		if num % i == 0 or num % (i + 2) == 0:
			return False
	return True

def bin_search(arr, low, high, val):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] == val:
			return mid
		elif arr[mid] < val:
			low = mid + 1
		else:
			high = mid - 1
	return -1

def sumofdigit(num):
	count = 0
	while num:
		count += num % 10
		num //= 10
	return count

def inputmatrix():
	(r, c) = iia()
	mat = [0] * r
	for i in range(r):
		mat[i] = iia()
	return (r, c, mat)

def prefix_sum(n, arr):
	for i in range(1, n):
		arr[i] += arr[i - 1]
	return arr

def binomial(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def divisors(n):
	res = []
	for i in range(1, ceil(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				res.append(i)
			else:
				res.append(i)
				res.append(n // i)
	return res
n = ii1()
fact = 1
for i in range(1, n + 1):
	fact2 = fact * i % mod
	fact = fact2
print((fact - pow(2, n - 1)) % mod)


import sys
read = lambda : sys.stdin.readline().strip()
n = int(read())
MOD = 1000000000.0 + 7
fact = 1
two_pow = 1
for i in range(2, n + 1):
	fact = i * fact % MOD
	two_pow = 2 * two_pow % MOD
print(int(int(fact - two_pow) % MOD))


import sys, math

def fact(n):
	res = 1
	for i in range(1, n + 1):
		res = res % mod * (i % mod) % mod
	return res

def pow(a, b):
	res = 1
	while b:
		if b % 2:
			res = res * a % mod
		a = a * a % mod
		b //= 2
	return res
mod = 1000000007
n = int(sys.stdin.readline())
print((fact(n) - pow(2, n - 1)) % mod)


import sys
import math
from collections import defaultdict, Counter
m = pow(10, 9) + 7
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % m
ans1 = ans - pow(2, n - 1, m)
if ans1 < 0:
	ans1 += m
print(ans1)


n = int(input())
mod = 10 ** 9 + 7
fact = 1
for i in range(2, n + 1):
	fact = fact * i % mod
ans = (fact - pow(2, n - 1, mod)) % mod
if ans < 0:
	ans = ans + mod
print(ans)


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x

def bo(i):
	return ord(i) - ord('A')

def ck(x, y):
	return int(bin(x)[2:] + bin(y)[2:], 2)
t = 1
mn = 10 ** 6 + 1
mod = 10 ** 9 + 7
jj = modInverse(6, mod)

def nc3(n):
	return (n - 1) % mod * n % mod % mod * (n - 2) % mod * jj % mod
fact = [1] * (mn + 1)
for i in range(1, mn + 1):
	fact[i] = i * fact[i - 1] % mod
while t > 0:
	t -= 1
	n = fi()
	print((fact[n] - pow(2, n - 1, mod) + mod) % mod)


def fact(n):
	p = 1
	for i in range(1, n + 1):
		p *= i
		p %= 10 ** 9 + 7
	return p
n = int(input())

def fp(a, n):
	if n == 0:
		return 1
	if n % 2:
		return a * fp(a, n // 2) * fp(a, n // 2) % (10 ** 9 + 7)
	else:
		return fp(a, n // 2) * fp(a, n // 2) % (10 ** 9 + 7)
print((fact(n) - fp(2, n - 1)) % (10 ** 9 + 7))


from sys import stdin, stdout
MOD = 10 ** 9 + 7

def fac(n, f):
	f.append(1)
	res = 1
	for i in range(1, n + 1):
		res *= i
		res %= MOD
		f.append(res)

def inv(a):
	return bp(a, MOD - 2, MOD)

def bp(x, y, m):
	if y == 0:
		return 1
	p = bp(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m

def C(n, c, f):
	p1 = f[n]
	p2 = f[n - c] * f[c] % MOD
	invp = inv(p2)
	res = p1 * invp % MOD
	return res

def cyclic_permutations(n, f):
	res = f[n] - 1
	res %= MOD
	for i in range(1, n):
		res -= C(n - 1, i, f)
		res %= MOD
	return res

def cyclic_permutations2(n):
	a = 1
	f = 1
	for i in range(1, n):
		a *= 2
		f *= i
		a %= MOD
		f %= MOD
	f *= n
	f %= MOD
	res = (f - a) % MOD
	return res
n = int(stdin.readline())
ans = cyclic_permutations2(n)
stdout.write(str(ans) + '\n')


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, recursion_limit, stack_size):
		setrecursionlimit(recursion_limit)
		threading.stack_size(stack_size)
		return None

class SOLVE:
	mod = 10 ** 9 + 7

	def twon(self, n):
		if n == 0:
			return 1
		x = self.twon(n // 2)
		if n % 2:
			return 2 * x ** 2 % self.mod
		else:
			return x ** 2 % self.mod

	def solve(self):
		R = stdin.readline
		W = stdout.write
		n = int(R())
		fact_n = 1
		for i in range(2, n + 1):
			fact_n *= i
			fact_n %= self.mod
		two_n = self.twon(n - 1)
		W('%d\n' % (fact_n - two_n + self.mod * (fact_n < two_n)))
		return 0

def main():
	s = SOLVE()
	s.solve()
threading.Thread(target=main).start()


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	n = int(input())
	ans = 1
	power = 1
	for i in range(1, n):
		ans = ans * i % MOD
		power = power * 2 % MOD
	ans = ans * n % MOD
	ans = (ans - power) % MOD
	print(ans)
t = 1
for _ in range(t):
	main()


n = int(input())
v = 10 ** 9 + 7

def modexp(a, b, c):
	if b == 1:
		return a
	if b % 2 == 0:
		y = modexp(a, b // 2, c)
		z = y * y
		if z >= c:
			z = z % c
		return z
	else:
		y = modexp(a, b // 2, c)
		z = y * y
		if z >= c:
			z = z % c
		x = a * z
		if x >= c:
			x = x % c
		return x
g = 1
for i in range(1, n + 1):
	g = g * i
	if g > v:
		g = g % v
h = modexp(2, n - 1, v)
o = g - h
print(o % v)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
for _ in range(1):
	n = L()[0]
	f = 1
	for i in range(2, n + 1):
		f = f * i % mod
	print((f - pow(2, n - 1, mod) + mod) % mod)


from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(n,) = mp()
mul = 1
sub = 1
for i in range(2, n + 1):
	mul = mul * i % (10 ** 9 + 7)
	sub = sub * 2 % (10 ** 9 + 7)
ans = mul % (10 ** 9 + 7) - sub % (10 ** 9 + 7)
cout(str(ans % (10 ** 9 + 7)))


m = 1000000007
n = int(input())

def modFact(n, m):
	if n >= m:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % m
	return result

def twoPowerMod(n, m):
	result = 1
	for i in range(n - 1):
		result = 2 * result % m
	return result
nf = modFact(n, m)
twopm = twoPowerMod(n, m) % m
print((nf + m - twopm) % m)


production = True
import sys, math, collections, bisect, itertools, heapq, decimal, random, copy, re

def input(f=0, m=0):
	if m > 0:
		return [input(f) for i in range(m)]
	else:
		l = sys.stdin.readline()[:-1]
		if f >= 10:
			u = False
			f = int(str(f)[-1])
		else:
			u = True
		if f == 0:
			p = [l]
		elif f == 1:
			p = list(map(int, l.split()))
		elif f == 2:
			p = list(map(float, l.split()))
		elif f == 3:
			p = list(l)
		elif f == 4:
			p = list(map(int, list(l)))
		elif f == 5:
			p = l.split()
		return p if u else p[0]

def out(l, f=0, n=True):
	if f == 0:
		p = str(l)
	elif f == 1:
		p = ' '.join(map(str, l))
	elif f == 2:
		p = '\n'.join(map(str, l))
	elif f == 3:
		p = ''.join(map(str, l))
	print(p, end='\n' if n else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(i, f=0):
	if f == 0:
		return list(map(int, i))
	elif f == 1:
		return list(map(str, i))
	elif f == 2:
		return list(map(list, i))
mb = 10 ** 9 + 7

def solve():
	n = input(11)
	t = 1
	for i in range(n - 1):
		t *= 2
		t %= mb
	a = 1
	for i in range(1, n + 1):
		a *= i
		a %= mb
	log(a, t)
	out((a - t) % mb)
	log()
	return
solve()


def fact(n):
	f = 1
	m = 1000000007
	for i in range(1, n + 1):
		f = f * i % m
	return f
n = int(input())
x = fact(n)
p = x - 2 ** (n - 1) % 1000000007
if p < 0:
	print(p + 1000000007)
else:
	print(p)


n = int(input())
(ans, store) = (1, 1)
while True:
	if ans == n + 1:
		break
	store = store * ans % (10 ** 9 + 7)
	ans += 1
a = 2 ** (n - 1) % (10 ** 9 + 7)
q = store - a
if q < 0:
	print(10 ** 9 + 7 + (store - a))
else:
	print(store - a)


n = int(input())
mod = 10 ** 9 + 7
ans = 1
for i in range(1, n + 1):
	ans *= i
	ans = ans % mod
two = 1
for i in range(n - 1):
	two *= 2
	two = two % mod
output = (ans - two) % mod
print(output)


def m(val):
	cal = 1
	for i in range(val, 0, -1):
		cal *= i
		cal = cal % (10 ** 9 + 7)
	return cal
n = int(input())
hold = pow(2, n - 2 + 1, 10 ** 9 + 7)
result = (m(n) - hold) % (10 ** 9 + 7)
print(result)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7

class ModTools:

	def __init__(self, MAX, MOD):
		MAX += 1
		self.MAX = MAX
		self.MOD = MOD
		factorial = [1] * MAX
		factorial[0] = factorial[1] = 1
		for i in range(2, MAX):
			factorial[i] = factorial[i - 1] * i % MOD
		inverse = [1] * MAX
		inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD)
		for i in range(MAX - 2, -1, -1):
			inverse[i] = inverse[i + 1] * (i + 1) % MOD
		self.fact = factorial
		self.inv = inverse

	def nCr(self, n, r):
		if n < r:
			return 0
		r = min(r, n - r)
		numerator = self.fact[n]
		denominator = self.inv[r] * self.inv[n - r] % self.MOD
		return numerator * denominator % self.MOD
N = INT()
mt = ModTools(N, MOD)
ans = (mt.fact[N] - pow(2, N - 1, MOD)) % MOD
print(ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	n = I()
	val = 1
	c = 1
	for i in range(1, n + 1):
		val *= i
		val %= P
		if i != n:
			c *= 2
			c %= P
	if val > c:
		print(val - c)
	else:
		print(P + val - c)
main()


N = 1000000007

def f(n):
	res = 1
	for x in range(1, n + 1):
		res *= x
		res %= N
	return res

def main():
	(n,) = map(int, input().split(' '))
	res = f(n)
	res -= 2 ** (n - 1) % N
	res %= 1000000007
	return res
print(main())


import sys
from collections import deque
pprint = lambda s: print(' '.join(map(lambda x: str(x), s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
mod = 1000000007
for _ in range(1):
	n = int(input())
	factorial = 1
	step = 1
	for i in range(n):
		factorial = factorial * (i + 1) % mod
		if i >= 1:
			step = step * 2 % mod
	print((factorial - step) % mod)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(1):
	n = int(input())
	print((factorial(n, MOD) - power(2, n - 1, MOD) + MOD) % MOD)


MOD = 10 ** 9 + 7

def factorial(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans

def pow(base, exp):
	ans = 1
	for i in range(exp):
		ans *= base
		ans %= MOD
	return ans

def main():
	n = int(input())
	print((factorial(n) - pow(2, n - 1) + MOD) % MOD)
main()


import sys
import collections

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
MOD = 1000000007
tests = 1

def exp(n):
	ans = 1
	for i in range(1, n):
		ans = ans * 2 % MOD
	return ans

def fact(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % MOD
	return ans
for _ in range(tests):
	n = int(input())
	print((fact(n) - exp(n)) % MOD)


n = int(input())
m = 10 ** 9 + 7
fact = 1
result = 1
t = n
while t:
	result = result * t % m
	t -= 1
	fact += 1
print(int((m + result - 2 ** (n - 1) % m) % m))


a = int(input())
mod = 10 ** 9 + 7
sum1 = 1
for i in range(2, a + 1):
	sum1 = sum1 * i % mod
print((sum1 - 2 ** (a - 1)) % mod)


import sys
from math import sqrt
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
print((ans - 2 ** (n - 1) % mod) % mod)


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
ans = 1
for i in range(1, n + 1):
	ans *= i
	ans %= MOD
ans -= power(2, n - 1, MOD)
ans %= MOD
print(ans)


MOD = int(1000000000.0 + 7)
n = int(input())
fac = 1
for i in range(n):
	fac = fac * (i + 1) % MOD
print((fac - pow(2, n - 1, MOD)) % MOD)


import io
import os
from collections import Counter, defaultdict, deque

def findCycle(source, getNbr):
	q = deque([source])
	dist = {source: 0}
	parent = {source: None}
	while q:
		node = q.popleft()
		d = dist[node]
		for nbr in getNbr(node):
			if nbr not in dist:
				q.append(nbr)
				dist[nbr] = d + 1
				parent[nbr] = node
			else:
				if dist[nbr] == d - 1:
					assert nbr == parent[node]
					continue
				assert dist[nbr] in [d, d + 1]
				path1 = [nbr]
				path2 = [node]
				while path1[-1] != path2[-1]:
					if dist[path1[-1]] >= dist[path2[-1]]:
						path1.append(parent[path1[-1]])
					else:
						path2.append(parent[path2[-1]])
				assert path1[-1] == path2[-1]
				path2.pop()
				return path1 + path2[::-1]
	return None

def solveBrute(N):
	MOD = 10 ** 9 + 7
	from itertools import permutations
	count = 0
	for perm in permutations(range(N)):

		def getNbr(i):
			ret = []
			for j in reversed(range(i)):
				if perm[j] > perm[i]:
					ret.append(j)
					break
			for j in range(i + 1, N):
				if perm[j] > perm[i]:
					ret.append(j)
					break
			return ret
		works = False
		for i in reversed(range(N)):
			works = findCycle(i, getNbr)
			if works:
				break
		if works:
			count += 1
	return count

def solve(N):
	MOD = 10 ** 9 + 7
	fact = [1]
	for i in range(1, N + 1):
		fact.append(fact[-1] * i % MOD)
	return (fact[N] - pow(2, N - 1, MOD)) % MOD
if False:
	for n in range(3, 20):
		print('N', n, solveBrute(n), solve(n))
		assert solveBrute(n) == solve(n)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N,) = [int(x) for x in input().split()]
ans = solve(N)
print(ans)


def modFact(n, p):
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
mod = 1000000007
n = int(input())
m = modFact(n, 1000000007)
m -= 2 ** (n - 1) % mod
print(m % mod)


x = int(input())
mod = 10 ** 9 + 7
fa = 1
for n in range(1, x + 1):
	fa = fa * n % mod
pw = 1
for n in range(x - 1):
	pw = 2 * pw % mod
print((fa - pw + mod) % mod)


n = int(input())
MOD = 10 ** 9 + 7
total = 1
for i in range(2, n + 1):
	total = total * i % MOD
remove = 1
for i in range(n - 1):
	remove = (remove << 1) % MOD
print((total - remove) % MOD)


import sys
import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(1):
	(n,) = I()
	fac = 1
	mod = 10 ** 9 + 7
	for i in range(2, n + 1):
		fac *= i
		fac %= mod
	print((fac - 2 ** (n - 1) % mod) % mod)


n = int(input())
MOD = 1000000000 + 7

def pow(a, b):
	res = 1
	for i in range(b):
		res = res * a
		res %= MOD
	return res

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res *= i
		res %= MOD
	return res
print((fact(n) - pow(2, n - 1) + 3 * MOD) % MOD)


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def fact(n, mod=1000000000.0 + 7):
	i = 1
	res = 1
	while i <= n:
		res = res * i % mod
		i += 1
	return res
n = inp()
f = fact(n)
p = int(1000000000.0 + 7)
l = pow(2, n - 1, p)
f -= l
if f < 0:
	f += p
print(int(f))


n = int(input())
ans = 1
mod = 10 ** 9 + 7
temp = 0.5
for i in range(n):
	ans = ans * (i + 1) % mod
	temp = temp * 2 % mod
print((ans - int(temp)) % mod)


def factorial(n):
	ans = 1
	for x in range(2, n + 1):
		ans = ans * x % 1000000007
	return ans
a = int(input())
temp = factorial(a) - pow(2, a - 1, 1000000007)
print(temp % 1000000007)


from sys import stdout, stdin
from collections import defaultdict
n = int(input())
z = 1
for i in range(n, 0, -1):
	z = z % 1000000007 * (i % 1000000007)
z = z % 1000000007
t = 1
for i in range(n - 1, 0, -1):
	t = t % 1000000007 * (2 % 1000000007)
t = t % 1000000007
ans = (z - t) % 1000000007
print(ans)


import math
n = int(input())
mod = 10 ** 9 + 7

def factorial(n):
	x = 1
	for i in range(1, n):
		x = (i + 1) * x % mod
	return x

def power_2(n):
	x = 1
	for i in range(1, n):
		x = 2 * x % mod
	return x
a = factorial(n) - power_2(n)
while a < 0:
	a = a + mod
print(a)


n = int(input())
m = 10 ** 9 + 7
f = 1
r = 1
count = 0
for i in range(1, n):
	f *= i
	r *= 2
	f %= m
	r %= m
f *= n
f %= m
f -= r
f %= m
print(f + m if f < 0 else f)


def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(input())
m = 1000000007
fact = 1
for i in range(1, n + 1):
	fact = fact * i % m
d = power(2, n - 1, m)
print((fact - d + 1000 * m) % m)


n = int(input())
m = int(1000000007)
a = int(1)
b = int(1)
for i in range(n - 1):
	a = a * (i + 1) % m
	b = b * 2 % m
a = a * n % m
ans = (a - b + m) % m
print(ans)


n = int(input())

def modpow():
	ret = 1
	for i in range(n - 1):
		ret *= 2
		ret %= 10 ** 9 + 7
	return ret

def perm():
	ret = 1
	for i in range(n):
		ret *= i + 1
		ret %= 10 ** 9 + 7
	return ret
print((perm() - modpow()) % (10 ** 9 + 7))


MOD = 10 ** 9 + 7

def find_cyclic_permutations(n):
	permutations = 1
	for i in range(1, n + 1):
		permutations *= i
		permutations %= MOD
	permutations_exclude_n = 1
	for i in range(n - 1):
		permutations_exclude_n *= 2
		permutations_exclude_n %= MOD
	cyclic_permutations = (permutations - permutations_exclude_n) % MOD
	return cyclic_permutations

def main():
	n = int(input())
	result = find_cyclic_permutations(n)
	print(result)
main()


I = input
a = int(I())
b = 1
c = 0.5
for i in range(a):
	b *= i + 1
	b = b % (1000000000.0 + 7)
	c = c * 2 % (1000000000.0 + 7)
print(int((b - c + (1000000000.0 + 7)) % (1000000000.0 + 7)))


from functools import lru_cache
from collections import defaultdict

def solution():
	n = int(input())
	n_fact = 1
	for i in range(1, n + 1):
		n_fact *= i
		n_fact %= 10 ** 9 + 7
	two_n = 1
	for _ in range(n - 1):
		two_n *= 2
		two_n %= 10 ** 9 + 7
	print((n_fact - two_n) % (10 ** 9 + 7))
solution()


import math
mod = 10 ** 9 + 7
fact = 1
n = int(input())
for i in range(2, n + 1):
	fact *= i
	fact %= mod
b = pow(2, n - 1)
print((fact - b) % mod)


def factmod(n, p):
	res = 1
	while n > 1:
		res = res * (p - 1 if n // p % 2 else 1) % p
		for i in range(2, n % p + 1):
			res = res * i % p
		n //= p
	return res % p

def modular_pow(base, index_n, modulus):
	c = 1
	for i in range(index_n):
		c = c * base % modulus
	return c
m = 10 ** 9 + 7
n = int(input())
print((factmod(n, m) - modular_pow(2, n - 1, m)) % m)


import sys
input = sys.stdin.readline
n = int(input())
m = 10 ** 9 + 7
fact = 1
for i in range(2, n + 1):
	fact = fact * i % m
sub = 1
for i in range(n - 1):
	sub = sub * 2 % m
ans = fact - sub
ans += m
ans %= m
print(ans)


n = int(input())
(f, p) = (1, 1)
for i in range(2, n + 1):
	f *= i
	p *= 2
	f %= 1000000007
	p %= 1000000007
ans = (f - p + 1000000007) % 1000000007
print(ans)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
n = int(input())
mod = pow(10, 9) + 7
a = 1
b = 1
for i in range(2, n + 1):
	a = a * i % mod
	b = b * 2 % mod
print((a - b) % mod)


n = int(input())
x = 2
m = 1000000007
for i in range(n - 2):
	x = x * 2 % m
y = 1
for i in range(2, n + 1):
	y = y * i % m
print((y - x + m) % m)


n = int(input())
fact = [1]
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	fact.append(fact[-1] * i % mod)
to_subtract = pow(2, n - 1, mod)
print((fact[-1] - to_subtract) % mod)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
from math import factorial as f
M = 10 ** 9 + 7
n = inp()
f = [1, 1]
for i in range(2, n + 1):
	f.append(f[-1] * i % M)
print((f[n] - pow(2, n - 1, M)) % M)


class BigMod(object):
	__mod = None

	def __init__(self, mod=1000000007):
		self.__mod = mod

	def big_mod(self, base, pw):
		if pw == 0:
			return 1
		r = self.big_mod(base, pw // 2)
		r = r * r % self.__mod
		if pw % 2:
			r = base * r % self.__mod
		return r

def solve():
	n = int(input())
	sol = BigMod()
	bad = sol.big_mod(2, n - 1)
	fact = 1
	for i in range(1, n + 1):
		fact *= i
		fact %= 1000000007
	res = (fact - bad + 1000000007) % 1000000007
	print(res)
solve()


m = 1000000007

def power(x):
	a = 2
	res = 1
	while x:
		if x & 1:
			res = res % m * (a % m) % m
		a = a % m * (a % m) % m
		x = x >> 1
	return res
n = int(input())
ans = 1
for i in range(2, n + 1):
	ans = ans % m * (i % m) % m
print((ans - power(n - 1) + m) % m)


def factorial(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % mod
	return ans
mod = int(1000000000.0 + 7)
n = int(input())
ans = factorial(n) - pow(2, n - 1, mod)
print((ans % mod + mod) % mod)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
FACT = [1]
for i in range(1, 1 * 10 ** 6 + 1):
	FACT.append(FACT[-1] * i % mod)
input = sys.stdin.readline
n = int(input())
pq = (FACT[n] - 2 ** (n - 1)) % mod
print(pq)


import sys
input = sys.stdin.readline
tmp = 10 ** 9 + 7
n = int(input())
x = 1
y = 1
for i in range(2, n + 1):
	x *= i
	x = x % tmp
for i in range(n - 1):
	y *= 2
	y = y % tmp
print((x - y + tmp) % tmp)


MOD = 10 ** 9 + 7

def fct(n):
	ans = 1
	i = 2
	while i <= n:
		ans = ans * i % MOD
		i += 1
	return ans
N = int(input())
ans = (fct(N) - pow(2, N - 1, MOD)) % MOD
print(ans)


modulx = 1000000000 + 7

def factorial(n):
	pro = 1
	for i in range(1, n + 1):
		pro = pro % modulx * (i % modulx) % modulx
	return pro % modulx
n = int(input())
sol = factorial(n) - 2 ** (n - 1) % modulx
print(sol % modulx)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def factorial(p):
	fact = [None] * (n + 1)
	fact[0] = 1
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % p
	return fact[n]
n = int(input())
mod = 10 ** 9 + 7
s = factorial(mod)
s -= 2 ** (n - 1)
s %= mod
print(s)


def fast_exp(b, e, m):
	r = 1
	if 1 & e:
		r = b
	while e:
		e >>= 1
		b = b * b % m
		if e & 1:
			r = r * b % m
	return r

def factorial(n, m):
	f = 1
	for i in range(1, n + 1):
		f = f * i % m
	return f
m = 1000000007
e = int(input())
if e == 0:
	print(0)
else:
	b = 2
	r = fast_exp(b, e - 1, m)
	fm = factorial(e, m)
	print((fm - r) % m)


def factorial(p):
	fact[0] = 1
	for i in range(1, n + 1):
		fact[i] = fact[i - 1] * i % p
n = int(input())
fact = [None] * (n + 1)
mod = 10 ** 9 + 7
factorial(mod)
s = fact[n]
s -= 2 ** (n - 1)
s %= mod
print(s)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = 1

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
m = 10 ** 9 + 7
while t:
	t -= 1
	n = int(fastinput())
	ans = (modFact(n, m) - pow(2, n - 1, m)) % m
	print(ans)


mod = 1000000000.0 + 7

def f(x):
	global mod
	pr = 1
	for i in range(2, x + 1):
		pr *= i
		pr %= mod
	return pr
n = int(input())
mod = int(1000000000.0 + 7)
if n == 3:
	print(2)
else:
	x = f(n) % mod - (1 << n - 1) % mod
	if x < 0:
		x += mod
	print(x)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
n = oint()
mod = 10 ** 9 + 7
ans = 1
for i in range(n - 1):
	ans *= 2
	if ans > mod:
		ans = ans % mod
f = 1
for i in range(n):
	f *= i + 1
	if f > mod:
		f %= mod
print((f + mod - ans) % mod)


def fast_pow(x, y):
	if y == 0:
		return 1
	p = fast_pow(x, y // 2)
	p = p * p % 1000000007
	if y % 2:
		p = p * x % 1000000007
	return p

def fact(n):
	res = 1
	for i in range(1, n + 1):
		res = res * i % 1000000007
	return res
n = int(input())
print((fact(n) + 1000000007 - fast_pow(2, n - 1)) % 1000000007)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	n = I()
	s = 1
	mod = 10 ** 9 + 7
	for i in range(1, n + 1):
		s *= i % mod
		s %= mod
	p = 1
	for i in range(n - 2):
		p *= 2
		p %= mod
	p *= 2
	p %= mod
	s = (s - p + mod) % mod
	print(s)
for _ in range(1):
	solve()


m = 10 ** 9 + 7

def sol(x):
	res = 1
	for i in range(1, x + 1):
		res = res * i % m
	return (res - pow(2, x - 1, m)) % m
print(sol(int(input())))


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline().rstrip()

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())
MOD = int(1000000000.0) + 7
MAXSIZE = int(1000000.0) + 3
STACK = {}

def cache(func):
	STACK[func.__name__] = []

	def new_func(n):
		stack = STACK[func.__name__]
		while n >= len(stack):
			stack.append(func(len(stack)))
		return stack[n]
	return new_func

@cache
def A000142(n):
	return 1 if n <= 1 else A000142(n - 1) * n % MOD

@cache
def A011782(n):
	return 1 if n <= 0 else (A011782(n - 1) << 1) % MOD

def A059204(n):
	return (A000142(n) - A011782(n - 1)) % MOD

def solve():
	return A059204(itg())

def main():
	print(solve())
DEBUG = 0
URL = 'https://codeforces.com/contest/1391/problem/C'
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
elif DEBUG == 2:
	main()
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	main()


M = 10 ** 9 + 7

def power_mod(a, b, m):
	res = 1
	for _ in range(b):
		res = res * (a % m) % m
	return res

def factorial_mod(n, m):
	res = 1
	for k in range(1, n + 1):
		res = res * (k % m) % m
	return res

def sub_mod(a, b, m):
	return (a % m + m - b % m) % m
n = int(input())
fac_res = factorial_mod(n, M)
pow_res = power_mod(2, n - 1, M)
ans = sub_mod(fac_res, pow_res, M)
print(ans)


import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7
MAX_N = 10 ** 6 + 10
fac = [1] + [0] * MAX_N
for i in range(1, MAX_N + 1):
	fac[i] = fac[i - 1] * i % MOD
ans = 0
n = int(input())
print((fac[n] - pow(2, n - 1, MOD)) % MOD)


def main():
	n = int(input())
	mod = 10 ** 9 + 7
	f = 1
	for i in range(1, n + 1):
		f *= i
		f %= mod
	f -= pow(2, n - 1, mod)
	f %= mod
	print(f)
main()


fef = 1
sus = int(input())
for piss in range(2, sus + 1):
	fef = fef * piss % 1000000007
cuc = 2 ** (sus - 1)
print((fef - cuc) % 1000000007)


x = int(input())
fa = [1] * (x + 1)
pw = [1] * (x + 1)
md = int(1000000000.0 + 7)
for n in range(1, x + 1):
	fa[n] = fa[n - 1] * n % md
	pw[n] = pw[n - 1] * 2 % md
print((fa[n] - pw[n - 1] + md) % md)


mod = 1000000007
n = int(input())
ans = 1
po = 1
for x in range(1, n):
	ans *= x
	ans %= mod
	po *= 2
	po %= mod
ans *= n
ans %= mod
ans -= po
ans %= mod
print(ans)


from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))

def factos(n, mod):
	arr = [0] * (n + 1)
	a = 1
	for i in range(1, n + 1):
		a *= i
		a %= mod
		arr[i] = a
	return arr

def solve():
	fact = factos(10 ** 6, MOD)
	for _ in range(1):
		n = nin()
		ans_.append((fact[n] - pow(2, n - 1, MOD)) % MOD)
solve()
for i in ans_:
	print(i)


def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p
p = 1000000007

def power(x, y, m=p):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	return p if y % 2 == 0 else x * p % m
N = 1000001
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = [None] * (N + 1)
fact = [None] * (N + 1)
factorial(p)

def pro(n):
	print((fact[n] - pow(2, n - 1)) % p)
pro(int(input()))


M = 10 ** 9 + 7

def factorial(N):
	if N == 0 or N == 1:
		return 1
	ans = 1
	for n in range(2, N + 1):
		ans *= n
		ans %= M
	return ans
N = int(input())
print((factorial(N) - pow(2, N - 1, M)) % M)


n = int(input())
prod = 1
power = 1
for i in range(1, n + 1):
	prod = prod * i
	prod = prod % 1000000007
	if i != n:
		power = power * 2
		power = power % 1000000007
print((prod - power + 1000000007) % 1000000007)


mod = 10 ** 9 + 7

def pow2(n):
	if n == 0:
		return 1
	if n % 2 == 0:
		return pow2(n // 2) ** 2 % mod
	return pow2(n - 1) * 2 % mod

def fact(n):
	res = 1
	for i in range(n):
		res *= i + 1
		res %= mod
	return res
n = int(input())
print((mod + fact(n) - pow2(n - 1)) % mod)


from array import array
n = int(input())
p = 1000000000 + 7
mod_fac = 1
store = array('Q', (1 for x in range(n)))
for x in range(1, n + 1):
	mod_fac = mod_fac * x % p
	store[x - 1] = mod_fac
answer = 2
for count in range(3, n):
	answer = (2 * answer + store[count - 1] * (count - 1)) % p
print(answer)


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
M = 1000000007

def factorial(n):
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f
n = iinput()
ans2 = (factorial(n) - math.ceil(2 ** (n - 1)) % M) % M
print(ans2)


n = int(input())
MOD = 10 ** 9 + 7
ans1 = 1
ans2 = 1
for i in range(1, n + 1):
	ans1 *= i
	ans1 %= MOD
for i in range(n - 1):
	ans2 *= 2
	ans2 %= MOD
print((ans1 - ans2) % MOD)


import sys
input = sys.stdin.readline
mod = int(1000000000.0) + 7

def f(n):
	ans = 1
	for i in range(1, n + 1):
		ans = ans * i % mod
	return ans
n = int(input())
print((f(n) % mod - 2 ** (n - 1) % mod) % mod)


n = int(input())
z = pow(2, n - 1, 1000000007)
x = 1
for i in range(n):
	x = x * (i + 1)
	x %= 1000000007
ans = x - z
print(ans % 1000000007)


n = int(input())
MOD = 10 ** 9 + 7
nump = 1
for i in range(2, n + 1):
	nump *= i
	nump %= MOD
sub = pow(2, n - 1, MOD)
ans = nump - sub
ans %= MOD
print(ans)


n = int(input())
ma = 1000000007
va = 1
for i in range(1, n + 1):
	va *= i % ma
	va = va % ma
ca = pow(2, n - 1) % ma
print((va - ca) % ma)


mod = 10 ** 9 + 7
n = int(input())
count = 0
fact = 2
nu = 3
for i in range(3, n + 1):
	count = (i - 2) * fact % mod + 2 * count % mod
	fact *= nu
	fact = fact % mod
	nu += 1
print(count % mod)


M = 10 ** 9 + 7
f = {0: 1}
for i in range(1, 10 ** 6 + 1):
	f[i] = f[i - 1] * i % M
n = int(input())
ans = (f[n] - pow(2, n - 1, M)) % M
print(ans)


n = int(input())
current = n
factorial = 1
power = 1
while current > 0:
	factorial *= current
	if current > 1:
		power *= 2
	factorial %= 10 ** 9 + 7
	power %= 10 ** 9 + 7
	current -= 1
print((factorial - power) % (10 ** 9 + 7))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
ans = 1
sub = 1
for i in range(1, n + 1):
	ans = ans * i % M
sub = 2 ** (n - 1)
sub %= M
print((ans - sub) % M)


def solve(n):
	mod = int(1000000000.0) + 7
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	div = 1
	for i in range(1, n):
		div *= 2
		div %= mod
	if (ans - div) % mod >= 0:
		print((ans - div) % mod)
	else:
		print((ans - div + mod) % mod)
n = int(input())
solve(n)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
MOD = int(1000000000.0) + 7

def factorial(n):
	r = 1
	for i in range(2, n + 1):
		r = r * i % MOD
	return r
from math import ceil

def A059204(n):
	return factorial(n) - ceil(1 << n - 1)
print(A059204(itg()) % MOD)


n = int(input())
from math import factorial
Ans = 1
con = 10 ** 9 + 7
x1 = 1
x2 = 1
for i in range(1, n + 1):
	x1 *= i
	x1 %= con
for i in range(n - 1):
	x2 *= 2
	x2 %= con
print((x1 + con - x2) % con)


import sys

def madd(a, b, m):
	return (a % m + b % m) % m

def mmul(a, b, m):
	return a % m * (b % m) % m

def msub(a, b, m):
	return (a % m - b % m + m) % m

def fact(n, mod):
	ans = 1
	for i in range(1, n + 1):
		ans = mmul(ans, i, mod)
	return ans
n = int(sys.stdin.readline())
mod = pow(10, 9) + 7
v1 = fact(n, mod)
v2 = pow(2, n - 1, mod)
v3 = msub(v1, v2, mod)
print(v3)


def fact(x):
	ans = 1
	for i in range(2, x + 1):
		ans *= i
		ans = ans % (1000000000 + 7)
	return ans
n = int(input())
ans = fact(n) - pow(2, n - 1, 1000000000 + 7)
if ans < 0:
	ans = ans + (1000000000 + 7)
print(ans)


import sys
import math
input = sys.stdin.readline
mod = 1000000007
n = int(input())
if n == 1 or n == 2:
	print(0)
fact = [0] * 1000003
fact[0] = 1
fact[1] = 1
for i in range(2, 1000001):
	fact[i] = fact[i - 1] * i % mod
ans = fact[n]
ans = ans - pow(2, n - 1, mod)
print(ans % mod)


modulo = 10 ** 9 + 7
factorial = 1
twopower = 1
n = int(input())
for i in range(n - 1):
	twopower = twopower * 2 % modulo
for i in range(1, n + 1):
	factorial = factorial * i % modulo
print((factorial - twopower) % modulo)


import math
p = 1000000007

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
print((modFact(n, p) - pow(2, n - 1, p)) % p)


import itertools
n = int(input())
l = []
mod = 10 ** 9 + 7
ans = 1
for i in range(1, n + 1):
	ans = ans * i % mod
ans1 = 1
for i in range(1, n):
	ans1 = ans1 * 2 % mod
print((ans - ans1 + mod) % mod)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
n = stdint()

def factorial(n):
	res = 1
	for i in range(1, n + 1):
		res = res % mod * (i % mod) % mod
	return res
res = (factorial(n) - pow(2, n - 1, mod)) % (10 ** 9 + 7)
print(res)


mod = 10 ** 9 + 7
n = int(input())
fac = 1
for i in range(2, n + 1):
	fac = fac * i % mod
x = fac
y = pow(2, n - 1, mod)
ans = (x - y) % mod
print(ans)


n = int(input())
mod = 10 ** 9 + 7

def modFact(n, p):
	if n >= p:
		return 0
	res = 1
	for i in range(1, n + 1):
		res = res * i % p
	return res
ans1 = modFact(n, mod)
ans2 = pow(2, n - 1, mod)
val = (ans1 - ans2) % mod
print(val)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
n = intIn()
MOD = 10 ** 9 + 7
fact = [1] * (n + 1)
for i in range(2, n + 1):
	fact[i] = fact[i - 1] * i % MOD
ans = (fact[n] - 2 ** (n - 1)) % MOD
print(ans)


n = int(input())
MOD = 1000000007
result = 1
for x in range(2, n + 1):
	result *= x
	result %= MOD
diff = 1
for x in range(n - 1):
	diff *= 2
	diff %= MOD
new_res = result - diff
new_res %= MOD
print(new_res)


mod = 10 ** 9 + 7
fac = [0, 1]
n = int(input())
for i in range(2, n + 1):
	fac.append(fac[-1] * i % mod)
ans = fac[n] - pow(2, n - 1, mod)
print(ans % mod)


def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
n = int(input())
MOD = 1000000007
x = modFact(n, MOD)
y = pow(2, n - 1, MOD)
ans = (x % MOD - y % MOD) % MOD
print(ans)


n = int(input())
p = int(1000000000.0 + 7)
fact = [1] * (n + 1)
for i in range(1, n + 1):
	fact[i] = i * fact[i - 1] % p
print((fact[n] - pow(2, n - 1, p)) % p)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
n = int(input())
mod = 10 ** 9 + 7
factorial = [1] * (n + 69)
twopow = [1] * (n + 69)
for i in range(1, n + 30):
	factorial[i] = factorial[i - 1] * i % mod
	twopow[i] = twopow[i - 1] * 2 % mod
print((factorial[n] - twopow[n - 1]) % mod)


n = int(input())
c = 1
for i in range(n):
	c *= i + 1
	c = c % (10 ** 9 + 7)
d = 2 ** (n - 1) % (10 ** 9 + 7)
if c - d < 0:
	print(10 ** 9 + 7 + c - d)
else:
	print(c - d)


INF = 10 ** 9 + 7
n = int(input())
antif = 1
cntf = 1
answer = 1
for i in range(1, n + 1):
	answer = answer * i % INF
answer -= 2 ** (n - 1) % INF
if answer < 0:
	answer += INF
print(answer)


def fact(a, m):
	ans = 1
	for i in range(2, a + 1):
		ans = i % m * ans % m % m
	return ans

def pow2(a, m):
	ans = 1
	for i in range(1, a):
		ans = ans * 2 % m
	return ans
n = int(input())
m = 1000000007
x = fact(n, m)
y = pow2(n, m)
val = x - y
if val < 0:
	val = val + m
print(val)


MOD = 10 ** 9 + 7

def fastExpo(num, pow, mod):
	ans = 1
	temp = num % mod
	while pow:
		if pow & 1:
			ans *= temp
			ans %= mod
		temp *= temp
		temp %= mod
		pow >>= 1
	return ans

def getFactorial(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i % MOD
		ans %= MOD
	return ans
n = int(input())
ans = getFactorial(n) - fastExpo(2, n - 1, MOD)
if ans < 0:
	ans += MOD
print(ans)


n = int(input())
mod = 1000000007
fact = 1
for i in range(1, n + 1):
	fact = fact % mod * (i % mod) % mod
k = pow(2, n - 1, mod)
ans = (fact % mod - k % mod) % mod
print(ans)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
mod = int(1000000000.0 + 7)

def modPow(x, y, p):
	(res, x) = (1, x % p)
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		(y, x) = (y >> 1, x * x % p)
	return res

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res *= i
		res %= mod
	return res
print((fact(n) - modPow(2, n - 1, mod)) % mod)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
t = 1
for _ in range(t):
	n = int(stdin.readline())
	MOD = 10 ** 9 + 7
	dp = [1] * (n + 1)
	for i in range(1, n + 1):
		dp[i] = dp[i - 1] * i % MOD
	ans = power(2, n - 1, MOD)
	print((dp[n] - ans) % MOD)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	n = ri()
	tot = 1
	mod = 10 ** 9 + 7
	for i in range(2, n + 1):
		tot = tot * i % mod
	tot = (tot - pow(2, n - 1, mod)) % mod
	print(tot)
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


n = int(input())
ans = 1
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	ans = ans * i % mod
ans -= (1 << n - 1) % mod
if ans < 0:
	ans += mod
print(ans)


n = int(input())
product = 1
for i in range(1, n + 1):
	product = product * i % 1000000007
res2 = pow(2, n - 1, 1000000007)
print((product % 1000000007 - res2 % 1000000007) % 1000000007)


n = int(input())
fact = 1
k = 1000000007
an = 1
for i in range(1, n + 1):
	fact = fact % k * i % k
	fact = fact % k
	if i != n:
		an = 2 * an % k
		an = an % k
ans = fact % k - an % k
print(ans % k)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def pow(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y % 2 == 1:
			res = res * x % p
		y = y // 2
		x = x ** x % p
	return res

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def solve():
	n = int(inp())
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= mod
	reduce = 1
	for i in range(n - 1):
		reduce *= 2
		reduce %= mod
	print((ans - reduce) % mod)
testcase(1)


import math
from collections import *
mod = 10 ** 9 + 7
fact = 1
n = int(input())
a = n
while a > 0:
	fact = fact * a % mod
	a -= 1
print((fact - pow(2, n - 1, mod)) % mod)


MOD = 10 ** 9 + 7
N = int(input())
p = pow(2, N - 1, MOD)
f = [1]
for i in range(1, N + 1):
	f.append(f[-1] * i % MOD)
print((f[N] - p + MOD) % MOD)


n = int(input())
factorial = [1]
x = 10 ** 9 + 7
for i in range(n - 1):
	factorial.append(factorial[-1] * (i + 2) % x)
a = 1
for i in range(n - 1):
	a *= 2
	a %= x
ans = factorial[-1] - a
print(ans % x)


from sys import stdin
n = int(stdin.readline())
d = 1
for i in range(2, n + 1):
	d = d * i % 1000000007
print((d - 2 ** (n - 1)) % 1000000007)


n = int(input())
MOD = 1000000007
fact = 1
unimodal_permutations = 1
for i in range(1, n):
	fact *= i
	unimodal_permutations <<= 1
	fact %= MOD
	unimodal_permutations %= MOD
fact *= n
fact %= MOD
fact -= unimodal_permutations
fact %= MOD
if fact < 0:
	fact += MOD
print(fact)


MOD = int(1000000000.0) + 7
fac = [1]
for i in range(int(1000000.0) + 10):
	fac.append(fac[-1] * (i + 1) % MOD)

def ans(n):
	global MOD
	prv = 0
	for i in range(3, n + 1):
		prv = ((i - 2) * fac[i - 1] % MOD + 2 * prv % MOD) % MOD
	return prv
print(ans(int(input())))


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def isSubsetSum(arr, n, summ):
	subarr = [[False for i in range(summ + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subarr[i][0] = True
	for i in range(1, summ + 1):
		subarr[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, summ + 1):
			if j < arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j]
			if j >= arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j] or subarr[i - 1][j - arr[i - 1]]
	return subarr[n][summ]

def bfs(v, adj, onpath):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def solution(n):
	if n < 3:
		return 0
	i = 0
	bad = 1
	p = NUMBER
	while i < n - 1:
		bad = bad * 2 % p
		i += 1
	fact = 1
	i = 2
	while i < n + 1:
		fact = fact * i % p
		i += 1
	return (fact - bad) % p

def main():
	T = 1
	for i in range(T):
		n = ri()
		x = solution(n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(input())
p = 1000000007
ans = 1
for i in range(1, n + 1):
	ans = ans * i
	ans = ans % p
b = power(2, n - 1, p)
print((ans - b) % p)


n = int(input())
mod = 10 ** 9 + 7
pre = [0] * 1000001
p = [0] * 1000001
(p[0], pre[0]) = (1, 1)
for i in range(1, 1000001):
	pre[i] = pre[i - 1] * i % mod
for i in range(1, 1000001):
	p[i] = p[i - 1] * 2 % mod
ans = 1
ans = (pre[n] - p[n - 1] + mod) % mod
print(ans)


from collections import *
from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
MOD = 1000000007
(n,) = rl()
r = 0
i1f = 1
for i in range(2, n + 1):
	r = (2 * r + i1f * (i - 2)) % MOD
	i1f = i1f * i % MOD
print(r)


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
MOD = 10 ** 9 + 7

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = II()
print((modFact(n, MOD) - power(2, n - 1, MOD)) % MOD)


def modfac(n, MOD):
	f = 1
	factorials = [1]
	for m in range(1, n + 1):
		f *= m
		f %= MOD
		factorials.append(f)
	inv = pow(f, MOD - 2, MOD)
	invs = [1] * (n + 1)
	invs[n] = inv
	for m in range(n, 1, -1):
		inv *= m
		inv %= MOD
		invs[m - 1] = inv
	return (factorials, invs)

def modnCr(n, r, mod, fac, inv):
	return fac[n] * inv[n - r] * inv[r] % mod
n = int(input())
ans = 0
mod = 10 ** 9 + 7
(fac, inv) = modfac(n + 10, mod)
for i in range(0, n):
	ans += modnCr(n - 1, i, mod, fac, inv)
	ans %= mod
print((fac[n] - ans) % mod)


from sys import stdin
from math import factorial
n = int(stdin.readline())
ans = 1
for i in range(1, n + 1):
	ans *= i % (10 ** 9 + 7)
	ans %= 10 ** 9 + 7
ans -= 2 ** (n - 1)
ans %= 10 ** 9 + 7
print(ans)


import sys, math
input = sys.stdin.readline
n = int(input())
total = 1
mod = 10 ** 9 + 7
for i in range(1, n + 1):
	total = i % mod * (total % mod) % mod
invert = 1
for i in range(1, n):
	invert = 2 % mod * (invert % mod) % mod
ans = (total - invert + mod) % mod
print(ans)


def power(k):
	ans = 1
	while k:
		k -= 1
		ans *= 2
		ans %= 1000000000.0 + 7
	return ans

def factorial(k):
	ans = 1
	while k:
		ans *= k
		k -= 1
		ans %= 1000000000.0 + 7
	return ans
n = int(input())
print(int((factorial(n) - power(n - 1)) % (1000000000.0 + 7)))


n = int(input())
f = n
factn = 1
while f > 0:
	factn = factn * f % 1000000007
	f -= 1
print((factn + 1000000007 - 2 ** (n - 1) % 1000000007) % 1000000007)


import math

def main():
	x = int(input())
	val = 1
	for i in range(2, x + 1):
		val *= i
		val %= 10 ** 9 + 7
	val -= 2 ** (x - 1)
	val %= 10 ** 9 + 7
	print(val)
main()


n = int(input())
mod = 1000 * 1000 * 1000 + 7
fac = 1
for i in range(1, n + 1):
	fac = fac * i % mod
deg = 1
for i in range(1, n):
	deg = deg * 2 % mod
print((fac - deg + mod) % mod)


MODULUS = 10 ** 9 + 7

def fac(n):
	ret = 1
	for i in range(1, n + 1):
		ret *= i
		ret %= MODULUS
	return ret
n = int(input())
total_perms = fac(n)
non_cyclic = pow(2, n - 1, MODULUS)
r = total_perms - non_cyclic
r %= MODULUS
r += MODULUS
r %= MODULUS
print(r)


def fact(n):
	num = 1
	while n > 1:
		num *= n
		n -= 1
		num %= 10 ** 9 + 7
	return num

def main():
	from sys import stdin, stdout
	import math
	N = int(input())
	print((fact(N) - pow(2, N - 1, 10 ** 9 + 7)) % (10 ** 9 + 7))
main()


mod = 10 ** 9 + 7
n = int(input())
f = 1
for i in range(2, n + 1):
	f = f * i
	f %= mod
r = pow(2, n - 1, mod)
s = (f - r) % mod
print(s)


n = int(input())
MOD = 1000000007

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def modExp(n, p):
	result = 1
	for i in range(n):
		result = result * 2 % p
	return result
print((modFact(n, MOD) - modExp(n - 1, MOD) + MOD) % MOD)


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
n = int(input())
curr = 4
mod = 10 ** 9 + 7
for i in range(n - 3):
	curr = curr * 2 % mod
m = 1
for i in range(1, n + 1):
	m = m * i % mod
print((m - curr + mod) % mod)


from functools import reduce
n = int(input())
MOD = 10 ** 9 + 7
num_permutations = reduce(lambda x, y: x * y % MOD, range(1, n + 1))
num_cyclic = 2 ** (n - 1) % MOD
print((num_permutations - num_cyclic + MOD) % MOD)


MOD = 1000000007

def fast_power(a, b):
	result = 1
	while b > 0:
		if b % 2 == 1:
			result = result * a % MOD
		b = b // 2
		a = a * a % MOD
	return result
n = int(input())
x = 1
for i in range(2, n + 1):
	x = x * i % MOD
y = fast_power(2, n - 1)
print((x - y) % MOD)


import sys, math
from collections import Counter, deque, defaultdict
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
C = lambda : input().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	fa = 1
	for i in range(1, n + 1):
		fa = i % mod * (fa % mod) % mod
	c = 1
	for i in range(n - 1):
		c = c % mod * 2 % mod
	print((fa - c) % mod)
for _ in range(1):
	solve()


modulo = 10 ** 9 + 7
n = int(input())
diff = 0
y = 2
time = 3
while time <= n:
	diff = diff * time + (time - 2) * y
	diff %= 10 ** 9 + 7
	y *= 2
	y %= 10 ** 9 + 7
	time += 1
print(diff)


import time
from collections import deque

def inpt():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpm():
	return map(int, input().split())

def modFact(n, p):
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def solve():
	m = 10 ** 9 + 7
	n = inpt()
	x = modFact(n, m)
	print((x - pow(2, n - 1) + m) % m)

def main():
	solve()
main()


mod = 10 ** 9 + 7
N = 10 ** 6
import sys
input = sys.stdin.buffer.readline

def power(a, n, mod):
	bi = str(format(n, 'b'))
	res = 1
	for i in range(len(bi)):
		res = res * res % mod
		if bi[i] == '1':
			res = res * a % mod
	return res

def main():
	n = int(input())
	fac = [1] * (N + 1)
	for i in range(N):
		fac[i + 1] = fac[i] * (i + 1) % mod
	P = [1] * (N + 1)
	for i in range(N):
		P[i + 1] = P[i] * 2 % mod
	ans = 0
	for i in range(1, n):
		temp = (n - 2 - (i - 1)) * fac[n - i] * P[i - 1]
		ans += temp
	ans %= mod
	print(ans)
main()


def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
n = int(input())
prod = 1
MOD = 1000000007
for i in range(1, n + 1):
	prod = prod % MOD * (i % MOD) % MOD
print((prod - power(2, n - 1, MOD)) % MOD)


i = n = int(input())
t = p = 1
mod = 10 ** 9 + 7
while i:
	t = t * i % mod
	i -= 1
print((t - 2 ** n // 2) % mod)


ll = lambda : list(map(int, input().split()))
lls = lambda : list(map(str, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
from sys import *
from datetime import datetime
from sys import stdin, stdout
import sys

def lcm(a, b):
	return a * b // gcd(a, b)
from collections import *

def modFact(n):
	p = 10 ** 9 + 7
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result
mod = 10 ** 9 + 7
n = ii()
s = modFact(n)
print((s - pow(2, n - 1, mod)) % mod)


import math

def factmod(n, p):
	res = 1
	while n > 1:
		res = res * (p - 1 if int(n / p) % 2 else 1) % p
		for i in range(2, n % p + 1):
			res = res * i % p
		n = int(n / p)
	return res % p

def binpow(a, n, p):
	if n == 0:
		return 1
	if n % 2 == 1:
		return binpow(a, n - 1, p) % p * a % p % p
	else:
		b = binpow(a, n // 2, p) % p
		return b % p * b % p % p
n = int(input())
print((factmod(n, 1000000007) - binpow(2, n - 1, 1000000007)) % 1000000007)