#include <bits/stdc++.h>
using namespace std;
const long long modn = 1000000007;
long long n, ans, s = 1;
long long first[200005], second[200005];
long long a[200005];
long long x, y;
void tur() {
  for (int i = 0; i < n - 1; i++) {
    a[i] = a[i] + s * a[i + 1];
    s *= -1;
  }
  n--;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
  if (n % 2 == 1) tur();
  second[1] = 1;
  for (int i = 2; i <= n / 2; i++) {
    second[i] = (-second[modn % i] * (modn / i)) % modn;
  }
  first[0] = 1;
  for (int i = 0; i < n / 2 - 1; i++) {
    first[i + 1] = (first[i] * (n / 2 - 1 - i)) % modn;
    first[i + 1] = (first[i + 1] * second[i + 1]) % modn;
  }
  for (int i = 0; i < n / 2; i++) {
    x = (x + a[2 * i] * first[i]) % modn;
    y = (y + a[2 * i + 1] * first[i]) % modn;
  }
  if (n == 0)
    ans = a[0] % modn;
  else if (n % 4 == 0)
    ans = (x - y) % modn;
  else if (n % 4 == 2)
    ans = (x + y) % modn;
  if (ans < 0) ans += modn;
  cout << ans << endl;
  return 0;
}
