#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
const long long E = (long long)1e9 + 7;
long long f[N], f1[N];
long long binpow(long long a, long long p) {
  long long x = 1;
  while (p) {
    if (p & 1) x = x * a % E;
    a = a * a % E;
    p /= 2;
  }
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    int e;
    cin >> e;
    cout << e;
    return 0;
  }
  vector<long long> a(n - n % 2);
  if (n % 2) {
    vector<long long> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i + 1 < n; i++)
      if (i % 2)
        a[i] = b[i] - b[i + 1];
      else
        a[i] = b[i] + b[i + 1];
  } else {
    for (int i = 0; i < n; i++) cin >> a[i];
  }
  n -= n % 2;
  long long t1 = 0, t2 = 0;
  f[0] = f1[0] = 1;
  for (int i = 1; i < N; i++) {
    f[i] = f[i - 1] * i % E;
    f1[i] = binpow(f[i], E - 2);
  }
  int m = n / 2 - 1;
  for (int i = 0; i < n; i += 2) {
    long long c = f[m] * f1[i / 2] % E * f1[m - i / 2] % E;
    t1 = (t1 + a[i] * c) % E;
    t2 = (t2 + a[i + 1] * c) % E;
  }
  if ((long long)n * (n - 1) / 2 % 2)
    cout << (t1 + t2 + E + E) % E;
  else
    cout << (t1 - t2 + E + E) % E;
  return 0;
}
