#include <bits/stdc++.h>
using namespace std;
struct Mod {
  static const int P = int(1e9 + 7);
  long long k;
  Mod() = default;
  Mod(const long long k) : k(k % P >= 0 ? k % P : k % P + P) {}
};
Mod operator+(const Mod a, const Mod b) { return a.k + b.k; }
Mod operator*(const Mod a, const Mod b) { return a.k * b.k; }
Mod power(const Mod x, const int k) {
  if (k == 0)
    return 1;
  else if (k % 2 == 0)
    return power(x * x, k / 2);
  else
    return x * power(x * x, k / 2);
}
Mod inverse(const Mod x) { return power(x, Mod::P - 2); }
Mod& operator+=(Mod& a, const Mod b) { return a = a + b; }
Mod solve(const int n, int sign, const vector<Mod>& a) {
  if (n == 1)
    return a[0];
  else if (n % 4 == 2) {
    const int m = (n - 2) / 2;
    vector<Mod> factorials(m + 1);
    factorials[0] = 1;
    for (int i = 1; i <= m; i++) factorials[i] = i * factorials[i - 1];
    vector<Mod> inverse_factorials(m + 1);
    inverse_factorials[m] = inverse(factorials[m]);
    for (int i = m; i >= 1; i--)
      inverse_factorials[i - 1] = i * inverse_factorials[i];
    const auto binomial = [&](const int k) {
      return factorials[m] * inverse_factorials[k] * inverse_factorials[m - k];
    };
    Mod result(0);
    int sign2 = 1;
    for (int i = 0; i < n; i++, sign2 *= sign)
      result += sign2 * binomial(i / 2) * a[i];
    return result;
  } else {
    vector<Mod> b;
    for (int i = 0; i + 1 < n; i++) {
      b.push_back(a[i] + sign * a[i + 1]);
      sign *= -1;
    }
    return solve(n - 1, sign, b);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<Mod> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = x;
  }
  cout << solve(n, 1, a).k << endl;
}
