#include <bits/stdc++.h>
using namespace std;
int n, flag;
long long s[201000];
long long inv(long long x) {
  return x == 1 ? 1 : (-(1000000007 / x) * inv(1000000007 % x) % 1000000007);
}
void turn() {
  for (int i = 1; i < n; i++)
    if (i & 1)
      s[i] = (s[i] + s[i + 1]) % 1000000007;
    else
      s[i] = (s[i] - s[i + 1]) % 1000000007;
  n--;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &s[i]);
  if (n == 1) {
    printf("%I64d\n", s[1]);
    return 0;
  }
  if (n & 1) turn();
  long long ans = 0, C = 1, k = 0, m = (n - 1) / 2, flag = (n % 4 == 0);
  for (int i = 1; i <= n; i++) {
    if (i & 1)
      ans = (ans + C * s[i] % 1000000007) % 1000000007;
    else if (flag)
      ans = (ans - C * s[i] % 1000000007) % 1000000007;
    else
      ans = (ans + C * s[i] % 1000000007) % 1000000007;
    if (!(i & 1)) {
      C = (C * (m - k) % 1000000007) * inv(k + 1) % 1000000007;
      k++;
    }
  }
  ans = (ans % 1000000007 + 1000000007) % 1000000007;
  printf("%I64d\n", ans);
}
