#include <bits/stdc++.h>
using namespace std;
class binomial_coefficient_t {
  size_t Radix, N;
  unsigned long long *factorial, *inverse;
  unsigned long long power_modulo(size_t x, size_t p) {
    unsigned long long y = 1, z = x;
    while (p != 0) {
      if (p & 1) y *= z, y %= Radix;
      z *= z, z %= Radix, p >>= 1;
    }
    return y;
  }

 public:
  binomial_coefficient_t(const size_t R, const size_t n) : Radix(R), N(n) {
    size_t p = N + 1;
    factorial = new unsigned long long[p], inverse = new unsigned long long[p];
    size_t i = 1;
    unsigned long long y = factorial[0] = 1;
    while (i != p) factorial[i] = (y *= i, y %= Radix), i++;
    inverse[i = N] = y = power_modulo(y, Radix - 2);
    size_t j = i;
    do inverse[--i] = (y *= j, y %= Radix), j = i;
    while (j != 0);
  }
  size_t binomial_coefficient(const size_t n, const size_t k) {
    unsigned long long y = factorial[n];
    return y *= inverse[k], y %= Radix, y *= inverse[n - k], y %= Radix;
  }
};
class alternating_add_and_subtract : public binomial_coefficient_t {
  static constexpr size_t Radix = 1000000007, N = 200000, aux = N + 1;
  size_t a[aux + 1], m, n;
  bool adding;
  size_t add(const size_t i, const size_t j) {
    if ((a[i] += a[j]) >= Radix) a[i] -= Radix;
    return a[i];
  }
  size_t subtract(const size_t i, const size_t j) {
    if (a[i] < a[j]) a[i] += Radix;
    return a[i] -= a[j];
  }
  size_t add_or_subtract(const size_t i, const size_t j) {
    return (adding ? add(i, j) : subtract(i, j));
  }
  void brute_force() {
    adding = true, n--;
    for (size_t i = 1, j = 2; i <= n; adding = !adding, i = j++)
      add_or_subtract(i, j);
  }
  size_t compute_aux(unsigned long long c, const size_t i) {
    c *= a[i];
    return a[aux] = c % Radix;
  }

 public:
  alternating_add_and_subtract() : binomial_coefficient_t(Radix, N) {
    scanf("%u", &n);
    for (size_t i = 1, number; i <= n; scanf("%u", &number), a[i++] = number)
      ;
    if (n % 2) brute_force();
    a[0] = a[1];
    m = n / 2, adding = (m % 2);
    if (n != 0) {
      add_or_subtract(0, 2);
      size_t c = m - 1;
      for (size_t i = c, j = 2, odd = 3, even = 4; j <= m; j++, odd++, even++)
        compute_aux(c, odd++), add(0, aux), compute_aux(c, even++),
            add_or_subtract(0, aux), c = binomial_coefficient(i, j);
    }
  }
  size_t solution() const { return a[0]; }
} problem;
int main() { printf("%u", problem.solution()); }
