#include <bits/stdc++.h>
using namespace std;
long long Fac[(220005)], ReN[(220005)], ReFac[(220005)];
long long D[(220005)], Shit[(220005)];
int A[(220005)];
int N;
long long Ans;
inline long long C(const int& n, const int& r) {
  return Fac[n] * ReFac[r] % (1000000007) * ReFac[n - r] % (1000000007);
}
int main() {
  Fac[0] = 1;
  for (int i = 1; i < (220005); i++) Fac[i] = Fac[i - 1] * i % (1000000007);
  ReN[1] = 1;
  for (int i = 2; i < (220005); i++)
    ReN[i] = (ReN[(1000000007) % i] * ((1000000007) / i) % (1000000007) * (-1) +
              (1000000007)) %
             (1000000007);
  ReFac[0] = 1;
  for (int i = 1; i < (220005); i++)
    ReFac[i] = ReFac[i - 1] * ReN[i] % (1000000007);
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  if (0 == N % 4) {
    for (int i = 0; i < N; i++) {
      if (i & 1)
        D[i] = -C(N / 2 - 1, i / 2);
      else
        D[i] = C(N / 2 - 1, i / 2);
    }
  } else if (2 == N % 4) {
    for (int i = 0; i < N; i++) D[i] = C(N / 2 - 1, i / 2);
  } else if (1 == N % 4) {
    for (int i = 0; i < N; i += 2) D[i] = C(N / 2, i / 2);
  } else {
    N -= 2;
    for (int i = 0; i < N; i += 2) Shit[i] = C(N / 2, i / 2);
    N += 2;
    D[0] = 1;
    for (int i = 1; i <= (N / 2); i += 2) D[i] = Shit[i - 1] * 2 % (1000000007);
    for (int i = 2; i <= (N / 2); i += 2)
      D[i] = (D[i + 1] - D[i - 1] + (1000000007)) % (1000000007) * ReN[2] %
             (1000000007);
    for (int i = N / 2 + 1; i < N; i++) {
      if (i & 1)
        D[i] = D[N - i - 1];
      else
        D[i] = -D[N - i - 1];
    }
  }
  for (int i = 0; i < N; i++) {
    Ans = ((Ans + (((long long)A[i] * D[i] % (1000000007) + (1000000007)) %
                   (1000000007))) %
               (1000000007) +
           (1000000007)) %
          (1000000007);
  }
  printf("%lld\n", Ans);
  return 0;
}
