#!/bin/python import sys n = int(raw_input().strip()) m = map(int, raw_input().strip().split(' ')) # your code goes here tot=0 if n<=2: tot=1 else: for i in range(n): #print (n-i)**i tot+= (n-i)**i print tot%(10**9+7)