#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (!n1) return n2;
  if (!n2) return n1;
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  base %= 1000000007;
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 1000000007;
    base = (base * base) % 1000000007;
    exponent /= 2;
  }
  ans %= 1000000007;
  return ans;
}
int arr[1000100 + 1];
long long fact[1000100 + 1];
long long C(int n, int r) {
  if (r < 0 || r > n) return 0;
  long long ret = fact[n];
  ret = (ret * powmod((fact[r] * fact[n - r]) % 1000000007, 1000000007 - 2)) %
        1000000007;
  return ret;
}
int main() {
  int n, i, j;
  fact[0] = 1;
  for (i = 1; i <= 1000100; i++) fact[i] = (i * fact[i - 1]) % 1000000007;
  scanf("%d", &n);
  long long answer = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
  }
  if (n == 1)
    answer = arr[1];
  else if (n % 2 == 0) {
    if (n % 4 == 0) {
      for (i = 1; i <= n; i += 2) {
        answer += ((1LL * arr[i] - arr[i + 1]) * C(n / 2 - 1, i / 2));
        answer = ((answer % 1000000007) + 1000000007) % 1000000007;
      }
    } else {
      for (i = 1; i <= n; i += 2) {
        answer += ((1LL * arr[i] + arr[i + 1]) * C(n / 2 - 1, i / 2));
        answer = ((answer % 1000000007) + 1000000007) % 1000000007;
      }
    }
  } else {
    for (i = 1; i < n; i++) {
      if (i & 1)
        arr[i] = arr[i] + arr[i + 1];
      else
        arr[i] = arr[i] - arr[i + 1];
    }
    n--;
    if (n % 4 == 0) {
      for (i = 1; i <= n; i += 2) {
        answer += ((1LL * arr[i] - arr[i + 1]) * C(n / 2 - 1, i / 2));
        answer = ((answer % 1000000007) + 1000000007) % 1000000007;
      }
    } else {
      for (i = 1; i <= n; i += 2) {
        answer += ((1LL * arr[i] + arr[i + 1]) * C(n / 2 - 1, i / 2));
        answer = ((answer % 1000000007) + 1000000007) % 1000000007;
      }
    }
  }
  printf("%lld\n", answer);
  return 0;
}
