#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const int mod = 1000000007;
int A[N];
long long int F[N], IF[N];
long long int _pow(long long int a, long long int b) {
  if (!b) return 1;
  if (b == 1) return a;
  if (b == 2) return a * a % mod;
  if (b & 1) {
    return a * _pow(a, b - 1) % mod;
  }
  return _pow(_pow(a, b / 2), 2);
}
void pre() {
  F[0] = 1;
  for (int i = 1; i < N; i++) F[i] = F[i - 1] * i % mod;
  IF[N - 1] = _pow(F[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; i--) {
    IF[i] = IF[i + 1] * (i + 1) % mod;
  }
}
long long int nCr(int n, int r) {
  if (r > n) return 0;
  return F[n] * (IF[n - r] * IF[r] % mod) % mod;
}
vector<int> solve(vector<int> a, int times, int sign) {
  if (!times) {
    return a;
  }
  vector<int> b;
  for (int i = 0; i < a.size() - 1; i++) {
    int val = a[i] + (sign * a[i + 1]);
    if (val >= mod) val -= mod;
    if (val < 0) val += mod;
    b.push_back(val);
    sign *= -1;
  }
  return solve(b, times - 1, sign);
}
vector<int> v;
int main() {
  pre();
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  if (n < 5) {
    v = solve(v, n - 1, 1);
    printf("%d\n", v[0]);
    return 0;
  }
  v = solve(v, (n - 5) % 4, 1);
  int x = v.size() / 2;
  long long int ans = 0;
  for (int i = 0; i < v.size(); i += 2) {
    ans += nCr(x, i / 2) * v[i];
    ans %= mod;
    if (ans < 0) ans += mod;
  }
  cout << ans << "\n";
  return 0;
}
