#include <bits/stdc++.h>
using namespace std;
const int inf = 2 * 1e9;
const int mod = 1e9 + 7;
const int maxn = 200005;
int n, m;
int arr[maxn], ob[maxn], fact[maxn], obr[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> arr[1];
  ob[1] = fact[1] = obr[1] = 1;
  for (int i = 2; i <= n; ++i) {
    cin >> arr[i];
    ob[i] = (mod - 1LL * (mod / i) * ob[mod % i] % mod) % mod;
    fact[i] = (1LL * i * fact[i - 1]) % mod;
    obr[i] = (1LL * obr[i - 1] * ob[i]) % mod;
  }
  int ans = 0;
  if (n % 4 == 0) {
    for (int i = 1; i <= n; i += 2) {
      int p1 = (n - 2) / 2, p2 = (i - 1) / 2;
      int c =
          (((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod + mod) % mod;
      if (c == 0) c = 1;
      ans = (1LL * ans + (1LL * c * (arr[i] - arr[i + 1])) % mod) % mod;
    }
  } else if (n % 4 == 1) {
    for (int i = 1; i <= n; i += 2) {
      int p1 = (n - 1) / 2, p2 = (i - 1) / 2;
      int c = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;
      if (c == 0) c = 1;
      ans = (1LL * ans + (1LL * c * arr[i]) % mod) % mod;
    }
  } else if (n % 4 == 2) {
    for (int i = 1; i <= n; ++i) {
      int p1 = (n - 2) / 2, p2 = (i - 1) / 2;
      int c = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;
      if (c == 0) c = 1;
      ans = (1LL * ans + (1LL * c * arr[i]) % mod) % mod;
    }
  } else {
    ans = arr[1];
    for (int i = 2; i <= n; i += 2) {
      int p1 = (n - 3) / 2, p2 = (i - 2) / 2;
      int c1 = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;
      p2 += 1;
      int c2 = ((1LL * fact[p1] * obr[p2]) % mod * obr[p1 - p2]) % mod;
      if (c1 == 0)
        c1 = 1;
      else if (c2 == 0)
        c2 = 1;
      ans = (1LL * ans + (1LL * arr[i] * 2 * c1) % mod +
             (1LL * arr[i + 1] * (c2 - c1)) % mod) %
            mod;
    }
  }
  ans = (ans + mod) % mod;
  cout << ans;
  return 0;
}
