a = [0, 0, 1] // for i in range(3, 1010); a.append((i - 1) * (a[i - 2] + a[i - 1])) while True: try: n = int(input()) print(a[n]) except: break