#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool isprime[1000000 + 5];
void init_prime() {
  fill(isprime, isprime + 1000000 + 5, true);
  isprime[0] = isprime[1] = false;
  for (int i = (0), loop_end_i = (1000000 + 5); i < (loop_end_i); i++) {
    if (isprime[i]) {
      for (int j = i * 2; j < 1000000; j += i) {
        isprime[j] = false;
      }
    }
  }
}
vector<long long> factors(long long n) {
  vector<long long> v;
  for (long long i = (0), loop_end_i = (1000000); i < (loop_end_i); i++) {
    if (!isprime[i]) continue;
    while (n % i == 0) {
      v.push_back(i);
      n /= i;
    }
  }
  if (n > 1) {
    v.push_back(n);
  }
  return v;
}
template <typename T = int>
class bit {
 public:
  T *bit_arr;
  int size;
  bit(int n) {
    size = n;
    bit_arr = new T[n];
    fill(bit_arr, bit_arr + n, 0);
  }
  ~bit() { delete bit_arr; }
  T sum(int a) {
    T ret = 0;
    while (a) {
      ret += bit_arr[a];
      a -= a & -a;
    }
    return ret;
  }
  T sum(int a, int b) { return sum(b) - sum(a); }
  T get(int a) { return sum(a, a + 1); }
  void add(int a, T x) {
    a++;
    while (a < size) {
      bit_arr[a] += x;
      a += a & -a;
    }
  }
  void set(int a, T x) { add(a, x - get(a)); }
};
template <typename T = int, class Compare = less<T> >
class rmq {
 public:
  int size;
  Compare comp;
  T *dat;
  T init;
  rmq(int n, T init_ = INT_MAX) {
    init = init_;
    size = 1;
    while (size < n) size *= 2;
    dat = new T[2 * size - 1];
    fill(dat, dat + (2 * size - 1), init);
  }
  ~rmq() { delete dat; }
  void set(int k, T a) {
    k += size - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2], comp);
    }
  }
  T get(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return init;
    if (a <= l && r <= b)
      return dat[k];
    else {
      T vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
      return min(vl, vr, comp);
    }
  }
  T get(int a, int b) { return get(a, b, 0, 0, size); }
};
int n;
long long a[201234], b[201234];
long long fact[2 * 201234];
inline long long MMOD(long long a) {
  if (a < 0) {
    return (a + ((-a) / 1000000007LL + 3) * 1000000007LL) % 1000000007LL;
  } else {
    return a % 1000000007LL;
  }
}
long long ppow(long long x, long long y) {
  long long ret = 1, tmp = x;
  while (y) {
    ((tmp) = MMOD(tmp));
    if (y % 2) {
      ret *= tmp;
      ((ret) = MMOD(ret));
    }
    y /= 2;
    tmp *= tmp;
  }
  return ret;
}
inline long long rev(long long q) { return ppow(q, 1000000007LL - 2); }
inline long long cc(int x, int y) {
  long long ret = 1;
  ret *= fact[x];
  ret *= rev(fact[y]);
  ((ret) = MMOD(ret));
  ret *= rev(fact[x - y]);
  ((ret) = MMOD(ret));
  return ret;
}
int main() {
  fact[0] = 1;
  for (int i = (1), loop_end_i = (2 * 201234); i < (loop_end_i); i++)
    fact[i] = MMOD(fact[i - 1] * i);
  { scanf("%d", &(n)); };
  for (int i = (0), loop_end_i = (n); i < (loop_end_i); i++) {
    scanf("%lld", &(a[i]));
  };
  int k = 1;
  while (n % 4 != 1) {
    for (int i = (0), loop_end_i = (n - 1); i < (loop_end_i); i++) {
      b[i] = a[i] + k * a[i + 1];
      ((b[i]) = MMOD(b[i]));
      k *= -1;
    }
    swap(a, b);
    n--;
  }
  long long ans = 0;
  for (int i = (0), loop_end_i = ((n + 1) / 2); i < (loop_end_i); i++) {
    ans += MMOD(a[2 * i] * cc((n - 1) / 2, i));
    ((ans) = MMOD(ans));
  }
  printf("%lld\n", ans);
}
