#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200001];
int data[201][201][201];
long long fact[200001];
long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
long long mod_inverse(long long a, long long m) {
  long long x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
long long mod_fact(long long n, long long p, long long& e) {
  e = 0;
  if (n == 0) return 1;
  long long res = mod_fact(n / p, p, e);
  e += n / p;
  if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
  return res * fact[n % p] % p;
}
long long mod_comb(long long n, long long k, long long p) {
  if (n < 0 || k < 0 || n < k) return 0;
  long long e1, e2, e3;
  long long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2),
            a3 = mod_fact(n - k, p, e3);
  if (e1 > e2 + e3) return 0;
  return a1 * mod_inverse(a2 * a3 % p, p) % p;
}
int main(void) {
  scanf("%d", &n);
  fact[0] = 1;
  fact[1] = 1;
  for (int i = 2; i <= n; i++) {
    fact[i] = (long long)fact[i - 1] * i % 1000000007LL;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  long long res = 0;
  if (n <= 4) {
    if (n == 1) {
      printf("%lld\n", a[0]);
    }
    if (n == 2) {
      printf("%lld\n", (a[0] + a[1]) % 1000000007LL);
    }
    if (n == 3) {
      printf("%lld\n",
             (a[0] + 2LL * a[1] - a[2] + 1000000007LL) % 1000000007LL);
    }
    if (n == 4) {
      printf("%lld\n",
             (a[0] - a[1] + a[2] - a[3] + 1000000007LL + 1000000007LL) %
                 1000000007LL);
    }
  } else {
    if (n % 4 == 2) {
      int v = (n - 2) / 2;
      for (int i = 0; i < n; i++) {
        long long val = mod_comb(v, i / 2, 1000000007LL) * a[i] % 1000000007LL;
        res = (res + val) % 1000000007LL;
      }
    }
    if (n % 4 == 0) {
      int v = (n - 2) / 2;
      for (int i = 0; i < n; i++) {
        long long val = mod_comb(v, i / 2, 1000000007LL) * a[i] % 1000000007LL;
        if (i % 2 == 0)
          res = (res + val) % 1000000007LL;
        else {
          res = (res - val + 1000000007LL) % 1000000007LL;
        }
      }
    }
    if (n % 4 == 3) {
      int v = (n - 3) / 2;
      for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n - 1; j++) {
          long long val =
              mod_comb(v, j / 2, 1000000007LL) * a[i + j] % 1000000007LL;
          if (i == 0) {
            res = (res + val) % 1000000007LL;
          } else {
            if (j % 2 == 0) {
              res = (res + val) % 1000000007LL;
            } else {
              res = (res - val + 1000000007LL) % 1000000007LL;
            }
          }
        }
      }
    }
    if (n % 4 == 1) {
      int v = (n - 1) / 2;
      for (int i = 0; i < n; i++) {
        if (i % 2 == 1) continue;
        long long val = mod_comb(v, i / 2, 1000000007LL) * a[i] % 1000000007LL;
        res = (res + val) % 1000000007LL;
      }
    }
    printf("%lld\n", res);
  }
  return 0;
}
