#include <bits/stdc++.h>
using namespace std;
int N;
long long arr[200010];
long long factorial[200010];
long long factinv[200010];
long long fact[200010];
long long ans;
long long pw(long long a, long long b) {
  a %= 1000000007;
  if (b == 0) {
    return 1ll;
  }
  if (b == 1) {
    return a;
  }
  long long res = pw(a, b / 2);
  if (b % 2) {
    return (((res * res) % 1000000007) * a) % 1000000007;
  }
  return (res * res) % 1000000007;
}
long long inv(long long a) { return pw(a, 1000000007 - 2); }
long long choose(long long a, long long b) {
  return ((factorial[a] * factinv[b] % 1000000007) * factinv[a - b]) %
         1000000007;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  if (fopen("cf815b.in", "r")) {
    freopen("cf815b.in", "r", stdin);
    freopen("cf815b.out", "w", stdout);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    arr[i] %= 1000000007;
  }
  factorial[0] = 1;
  for (int i = 1; i <= N; i++) {
    factorial[i] = factorial[i - 1] * i;
    factorial[i] %= 1000000007;
  }
  for (int i = 0; i <= N; i++) {
    factinv[i] = inv(factorial[i]);
  }
  if (N % 4 == 0) {
    long long choosev = (N - 2) / 2;
    for (int i = 0; i < N; i++) {
      fact[i] = choose(choosev, i / 2);
      if (i % 2) {
        fact[i] *= (1000000007 - 1);
      }
      fact[i] %= 1000000007;
    }
  }
  if (N % 4 == 1) {
    long long choosev = (N - 1) / 2;
    for (int i = 0; i < N; i += 2) {
      fact[i] = choose(choosev, i / 2);
    }
  }
  if (N % 4 == 2) {
    long long choosev = (N - 2) / 2;
    for (int i = 0; i < N; i++) {
      fact[i] = choose(choosev, i / 2);
    }
  }
  if (N % 4 == 3) {
    long long choosev = (N - 3) / 2;
    fact[0] = 1;
    fact[N - 1] = 1000000007 - 1;
    for (int i = 1; i < N - 1; i++) {
      if (i % 2) {
        fact[i] = choose(choosev, (i - 1) / 2) + choose(choosev, (i - 1) / 2);
      } else {
        fact[i] = choose(choosev, (i / 2)) - choose(choosev, (i - 1) / 2);
      }
      fact[i] %= 1000000007;
      fact[i] += 1000000007;
      fact[i] %= 1000000007;
    }
  }
  for (int i = 0; i < N; i++) {
    cerr << fact[i] << ' ';
    ans += fact[i] * arr[i];
    ans %= 1000000007;
  }
  cout << ans << '\n';
  return 0;
}
