#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007, a[200007], a1[200007], x[200007], y[200007],
          f[200007], fi[200007];
long long comb(long long n, long long k) {
  if (n < 0 || k > n) return 0;
  long long val = (f[n] * fi[k]) % mod;
  return (val * fi[n - k]) % mod;
}
void euclid(long long a, long long b, long long& x, long long& y) {
  if (a % b == 0) {
    x = 0;
    y = 1;
    return;
  }
  euclid(b, a % b, x, y);
  int temp = x;
  x = y;
  y = temp - y * (a / b);
}
long long inverse(long long a) {
  long long x, y;
  euclid(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
int main() {
  long long n, s1, s2, i;
  cin >> n;
  f[0] = 1;
  fi[0] = 1;
  for (i = 1; i <= n; i++) {
    f[i] = (f[i - 1] * i) % mod;
    fi[i] = inverse(f[i]) % mod;
  }
  for (i = 0; i < n; i++) cin >> a[i];
  if (n == 1)
    cout << a[0] << endl;
  else {
    if (n % 2) {
      for (i = 1; i < n; i++) {
        if (i % 2)
          a1[i - 1] = a[i] + a[i - 1];
        else
          a1[i - 1] = a[i - 1] - a[i] + mod;
        a1[i - 1] %= mod;
      }
      for (i = 0; i < n; i++) a[i] = a1[i];
      n--;
    }
    for (i = 0; i < n / 2; i++) {
      x[i] = a[2 * i];
      y[i] = a[2 * i + 1];
    }
    s1 = s2 = 0;
    for (i = 0; i < n / 2; i++) {
      s1 += (x[i] * comb(n / 2 - 1, i)) % mod;
      s1 %= mod;
      s2 += (y[i] * comb(n / 2 - 1, i)) % mod;
      s2 %= mod;
    }
    if (((n * (n - 1)) / 2) % 2)
      cout << (s1 + s2) % mod << endl;
    else
      cout << (s1 - s2 + mod) % mod << endl;
  }
  return 0;
}
