#include <bits/stdc++.h>
using namespace std;
int p[1000050], t[1000050], f[1000050], a[1000050];
long long Pow(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % 1000000007)
    if (b & 1) ans = ans * a % 1000000007;
  return ans;
}
int C(int n, int m) {
  int ans = 1ll * p[n] * Pow(p[m], 1000000007 - 2) % 1000000007 *
            Pow(p[n - m], 1000000007 - 2) % 1000000007;
  return ans;
}
int main() {
  int n, i, ans;
  for (p[0] = i = 1; i <= 200000; i++) p[i] = 1ll * p[i - 1] * i % 1000000007;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (n % 4 == 0) {
    for (i = 1; i <= n; i++)
      if (i & 1)
        t[i] = C(n / 2 - 1, (i - 1) / 2);
      else
        t[i] = -C(n / 2 - 1, (i - 1) / 2);
  } else if (n % 4 == 1) {
    for (i = 1; i <= n; i++)
      if (i & 1) t[i] = C(n / 2, i / 2);
  } else {
    for (i = 1; i <= n; i++) {
      t[i] = C(n / 2 - 1, (i - 1) / 2);
    }
    if (n % 4 == 3) {
      f[1] = 1;
      f[n] = -1;
      for (i = 2; i < n; i++)
        if (i & 1)
          f[i] = t[i] - t[i - 1];
        else
          f[i] = t[i] + t[i - 1];
      memcpy(t, f, sizeof(t));
    }
  }
  ans = 0;
  for (i = 1; i <= n; i++) ans = (1ll * t[i] * a[i] + ans) % 1000000007;
  printf("%d\n", (ans + 1000000007) % 1000000007);
  return 0;
}
