#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int power(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int a[200010];
int main() {
  int n, u;
  scanf("%d", &n);
  int ans = 0;
  int flag[] = {1, 1, -1, -1};
  int mid = 1;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  if (n & 1) {
    for (int i = 0; i < n - 1; i++) {
      if (~i & 1)
        a[i] += a[i + 1];
      else
        a[i] -= a[i + 1];
      a[i] = (a[i] % 1000000007 + 1000000007) % 1000000007;
    }
    n--;
  }
  if (n == 0) {
    printf("%d\n", a[0]);
    return 0;
  }
  int k = n / 2;
  for (int i = 0; i < k; i++) {
    ans += (long long)a[i * 2] * mid % 1000000007;
    ans %= 1000000007;
    mid = (long long)mid * (k - i - 1) % 1000000007 *
          power(i + 1, 1000000007 - 2) % 1000000007;
  }
  int ok;
  if (k & 1)
    ok = 1;
  else
    ok = -1;
  mid = 1;
  for (int i = 0; i < k; i++) {
    ans += (long long)a[i * 2 + 1] * mid * ok % 1000000007;
    ans %= 1000000007;
    mid = (long long)mid * (k - i - 1) % 1000000007 *
          power(i + 1, 1000000007 - 2) % 1000000007;
  }
  cout << (ans + 1000000007) % 1000000007 << endl;
  return 0;
}
