#include <bits/stdc++.h>
using namespace std;
long long a[4][222222];
long long p = 1000000007;
long long fc[222222];
long long fastv(long long v, int s) {
  if (s == 0) {
    return 1;
  }
  long long x = fastv(v, s / 2);
  x = (x * x) % p;
  if (s & 1) {
    x = (x * v) % p;
  }
  return x;
}
int main() {
  int n;
  scanf("%i", &n);
  fc[0] = 1;
  for (int i = 1; i <= n; i++) {
    fc[i] = (fc[i - 1] * i) % p;
  }
  for (int i = 0; i < (n - 1) / 2; i++) {
    int nn = (n - 1) & (~3);
    nn = nn / 2;
    long long cc = fc[nn] * fastv(fc[i], p - 2);
    cc %= p;
    cc = (cc * fastv(fc[nn - i], p - 2)) % p;
    a[0][i * 2 + 1] = cc;
    a[0][nn * 2 + 1 - i * 2] = cc;
  }
  for (int i = 1 + ((n - 1) & ~3); i < n; i++) {
    for (int j = 1; j <= i + 1; j++) {
      if (j % 2 == 0) {
        a[i % 4][j] = a[(i + 3) % 4][j - 1];
        if ((i + j) % 2 == 1) {
          a[i % 4][j] -= a[(i + 3) % 4][j];
        } else {
          a[i % 4][j] += a[(i + 3) % 4][j];
        }
      } else {
        a[i % 4][j] = a[(i + 3) % 4][j];
        if ((i + j) % 2 == 1) {
          a[i % 4][j] -= a[(i + 3) % 4][j - 1];
        } else {
          a[i % 4][j] += a[(i + 3) % 4][j - 1];
        }
      }
      a[i % 4][j] %= p;
    }
  }
  if (n == 1) {
    a[0][1] = 1;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int m;
    scanf("%i", &m);
    ans = (a[n - 1 & 3][i + 1] * m + ans) % p;
  }
  if (ans < 0) {
    ans += p;
  }
  printf("%I64d", ans);
}
