#include <bits/stdc++.h>
using namespace std;
long long fact[200005], inv[200005];
int arr[200005];
long long quick_pow(long long a, int n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    n >>= 1;
  }
  return res;
}
inline long long C(int n, int m) {
  return fact[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int main() {
  fact[0] = inv[0] = 1;
  for (int i = 1; i < 200005; i++) {
    fact[i] = fact[i - 1] * i % 1000000007;
    inv[i] = quick_pow(fact[i], 1000000007 - 2);
  }
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  if (n == 1) {
    printf("%d\n", arr[0]);
    return 0;
  }
  if (n & 1) {
    int cur = 0;
    for (int i = 0; i < n - 1; i++) {
      arr[i] = ((arr[i] + (cur ? -arr[i + 1] : arr[i + 1])) % 1000000007 +
                1000000007) %
               1000000007;
      cur ^= 1;
    }
    n--;
  }
  long long x = 0, y = 0;
  for (int i = 0; i < n; i += 2)
    x = (x + C((n >> 1) - 1, i >> 1) * arr[i] % 1000000007) % 1000000007;
  for (int i = 1; i < n; i += 2)
    y = (y + C((n >> 1) - 1, i >> 1) * arr[i] % 1000000007) % 1000000007;
  printf("%lld\n", ((x + (((n >> 1) & 1) ? y : -y)) % 1000000007 + 1000000007) %
                       1000000007);
  return 0;
}
