#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 2e5 + 10;
const int p = 1e9 + 7;
int a[MAXN];
int b[MAXN];
int power(int x, int times) {
  if (times == 0) return 1;
  int tmp = power(x, times / 2);
  if (times & 1) return 1ll * tmp * tmp % p * x % p;
  return 1ll * tmp * tmp % p;
}
int getrev(int x) { return power(x, p - 2); }
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int now = 1;
  while (n % 4 != 1) {
    for (int i = 1; i < n; ++i, now *= -1)
      b[i] = (1ll * a[i] + 1ll * now * a[i + 1]) % p;
    for (int i = 1; i < n; ++i) a[i] = b[i];
    n--;
  }
  long long ans = 0;
  int half = (n + 1) / 2 - 1;
  now = 1;
  int up = half, down = 1;
  for (int i = 1; i <= n; i += 2) {
    ans = (ans + 1ll * a[i] * now) % p;
    now = 1ll * now * up % p * getrev(down) % p;
    up--, down++;
  }
  ans %= p;
  cout << (ans + p) % p << endl;
  return 0;
}
