#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SZ = 2e5 + 100;
int n, m1, m2;
int a[SZ];
int b1[SZ];
int b2[SZ];
int fact[SZ];
int inv[SZ];
int gcdex(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  int x1, y1;
  int d = gcdex(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
void init() {
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) {
    fact[i] = fact[i - 1] * (long long)i % MOD;
  }
  for (int i = 0; i < SZ; i++) {
    int x, y;
    gcdex(fact[i], MOD, x, y);
    inv[i] = (x % MOD + MOD) % MOD;
  }
}
int c(int n, int k) {
  return (long long)fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}
int main() {
  init();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << a[0] << endl;
    return 0;
  }
  int currop = 0;
  while (1) {
    if ((n & 1) == 0 && currop == 0) {
      break;
    }
    for (int i = 0; i < n - 1; i++) {
      if (currop == 0) {
        a[i] = ((a[i] + a[i + 1]) % MOD + MOD) % MOD;
      } else {
        a[i] = ((a[i] - a[i + 1]) % MOD + MOD) % MOD;
      }
      currop = !currop;
    }
    n--;
    if (n == 1) {
      cout << a[0] << endl;
      return 0;
    }
  }
  m1 = m2 = 0;
  for (int i = 0; i < n; i++) {
    if (i & 1) {
      b2[m2++] = a[i];
    } else {
      b1[m1++] = a[i];
    }
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < m1; i++) {
    c1 = c1 + (long long)c(m1 - 1, i) * b1[i] % MOD;
    if (c1 < 0) {
      c1 += MOD;
    }
    c1 %= MOD;
  }
  for (int i = 0; i < m2; i++) {
    c2 = c2 + (long long)c(m2 - 1, i) * b2[i] % MOD;
    if (c2 < 0) {
      c2 += MOD;
    }
    c2 %= MOD;
  }
  int ans = 0;
  if (n & 2) {
    ans = c1 + c2;
  } else {
    ans = c1 - c2;
  }
  if (ans < 0) {
    ans += MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
