package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	xx := make([]int64, n)

	for i := 0; i < n; i++ {
		xx[i] = getNextInt64(scanner)
	}
	var ans, mod int64
	mod = int64(1e9 + 7)

	tt := make([]int64, n)
	tt[0] = 1
	for i := 1; i < n; i++ {
		tt[i] = (tt[i-1] * 2) % mod
	}
	ff := make([]int64, n)
	ff[0] = 1
	for i := 1; i < n; i++ {
		ff[i] = ff[i-1] * int64(i) % mod
	}

	cm := Com{}
	cm.init(n)
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			rest := j + n - i - 1
			if i != n-1 {
				rest--
			}
			ans += (((ff[rest] * (xx[i] - xx[j]) % mod) * ff[i-j-1]) % mod) * cm.calc(n-1, rest)
			ans %= mod
		}
	}
	fmt.Fprintln(writer, ans)
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(1e9 + 7)
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1] * int64(i+1) % cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}
