#include <bits/stdc++.h>
using namespace std;
long long modulo(long long n) {
  n = n % 1000000007;
  if (n < 0) n += 1000000007;
  return n;
}
int calc(vector<int> v) {
  class subcalc {
   public:
    static long long modpow(const int num, int p) {
      if (p == 0)
        return 1;
      else if (p == 1)
        return modulo(num);
      long long res = modpow(num, p / 2);
      res = modulo(res * res);
      if (p % 2 != 0) {
        res *= num;
      }
      return modulo(res);
    }
    static long long modfac(int num) {
      static int fac[200000 + 1] = {1};
      static int top = 0;
      if (num <= top) return fac[num];
      long long res = fac[top];
      for (int i = top + 1; i <= num; i++) {
        res = modulo(res * i);
        fac[i] = res;
      }
      top = num;
      return fac[num];
    }
    static int comb(int n, int k) {
      return modulo(modfac(n) *
                    modpow(modulo(modfac(k) * modfac(n - k)), 1000000007 - 2));
    }
    static int calc(vector<int> subv) {
      int n = subv.size() - 1;
      int res = 0;
      for (int k = 0; k <= n; k++) {
        res += modulo(static_cast<long long>(subv[k]) * comb(n, k));
        res = modulo(res);
      }
      return res;
    }
  };
  vector<int> odd(v.size() / 2);
  vector<int> even(v.size() / 2);
  for (int i = 0; i < v.size(); i++) {
    if (i % 2 == 0) {
      odd[i / 2] = v[i];
    } else {
      even[i / 2] = v[i];
    }
  }
  int res;
  if (v.size() % 4 == 0) {
    res =
        modulo(modulo(subcalc::calc(odd)) + modulo(-1ll * subcalc::calc(even)));
  } else {
    res = modulo(modulo(subcalc::calc(odd)) + modulo(subcalc::calc(even)));
  }
  return modulo(res);
}
int main() {
  int count;
  scanf("%d", &count);
  vector<int> num[2];
  num[0].resize(count);
  num[1].resize(count);
  for (vector<int>::iterator it = num[0].begin(); it != num[0].end(); it++) {
    scanf("%d", &(*it));
  }
  bool isplus = true;
  int idx = 0;
  int nidx = 1;
  for (int i = 0; i < count; i++) {
    if (isplus && (count - i) % 2 == 0) {
      vector<int> temp_vec(num[idx].begin(), num[idx].end() - i);
      num[nidx][0] = calc(temp_vec);
      break;
    }
    for (int j = 0; j < count - i - 1; j++) {
      if (isplus) {
        num[nidx][j] = modulo(num[idx][j] + num[idx][j + 1]);
        isplus = false;
      } else {
        num[nidx][j] = modulo(num[idx][j] + modulo(-1ll * num[idx][j + 1]));
        isplus = true;
      }
    }
    idx = nidx;
    nidx = 1 - idx;
  }
  int res = num[nidx][0];
  printf("%d\n", modulo(res));
  return 0;
}
