#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const long double PI = acos(-1);
int n;
vector<long long> x(100010);
map<vector<bool>, long long> dp;
long long f(vector<bool> t) {
  if (dp[t]) return dp[t];
  int ne = 0;
  while (ne < n && !t[ne]) ne++;
  if (ne >= n) return 0;
  int ans = 0;
  for (int64_t i = (0); i < (n - 1); i++) {
    if (t[i]) {
      int next = i + 1;
      while (next < n && !t[next]) next++;
      ans += x[next] - x[i];
      ans %= (1000000007);
      t[i] = 0;
      ans += f(t);
      ans %= (1000000007);
      t[i] = 1;
    }
  }
  dp[t] = ans % (1000000007);
  return ans;
}
void solve() {
  cin >> n;
  for (int64_t i = (0); i < (n); i++) cin >> x[i];
  vector<bool> flag(n, 1);
  cout << f(flag) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
