#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
int PowAndMod(int base, int exp, int mod) {
  if (exp == 0) return 1;
  if (exp % 2 == 1) {
    return (base * 1LL * (PowAndMod(base, exp - 1, mod))) % MOD;
  } else {
    int tmp = PowAndMod(base, exp / 2, mod);
    return (tmp * 1LL * tmp) % MOD;
  }
}
int inv(int a, int mod) { return PowAndMod(a, mod - 2, mod); }
vector<int> solve(const int &n) {
  if (n == 1) return vector<int>{1};
  if (n % 4 == 1) {
    vector<int> res(n);
    int t = (n - 1) / 2;
    int c = 1;
    for (int i = 0; i < t; i++) {
      res[2 * i] = c;
      res[2 * i + 1] = 0;
      c = (c * 1LL * (t - i)) % MOD;
      c = (c * 1LL * inv(i + 1, MOD)) % MOD;
    }
    res.back() = 1;
    return res;
  }
  if (n % 4 == 2) {
    vector<int> res = solve(n - 1);
    for (int i = 0; i < n - 1; i++) {
      if (res[i] == 0) res[i] = res[i - 1];
    }
    res.push_back(1);
    return res;
  }
  if (n % 4 == 3) {
    vector<int> tmp = move(solve(n - 1));
    vector<int> res(n);
    res[0] = 1;
    for (int i = 1; i < n - 1; i++) {
      res[i] =
          (tmp[i] + 0LL + (i % 2 == 1 ? 1 : -1) * tmp[i - 1] + 0LL + MOD) % MOD;
    }
    res[n - 1] = MOD - 1;
    return res;
  }
  if (n % 4 == 0) {
    vector<int> res(n);
    int t = n / 2 - 1;
    int c = 1;
    for (int i = 0; i <= t; i++) {
      res[2 * i] = c;
      res[2 * i + 1] = MOD - c;
      c = (c * 1LL * (t - i)) % MOD;
      c = (c * 1LL * inv(i + 1, MOD)) % MOD;
    }
    return res;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> res = solve(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int num;
    scanf("%d", &num);
    ans = (ans + num * 1LL * res[i]) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}
