#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e6 + 6;
int fat[MAX], arr[MAX], coef[MAX], tmp[MAX], helper[MAX];
int n;
inline int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (0 > a) {
    a += MOD;
  }
  return a;
}
inline int mult(int a, int b) { return (1LL * a * b) % MOD; }
inline int f_exp(int x, int exp) {
  if (exp == 0) {
    return 1;
  } else if (exp & 1) {
    return mult(x, f_exp(x, exp - 1));
  }
  return f_exp(mult(x, x), exp >> 1);
}
inline int inv(int x) { return f_exp(x, MOD - 2); }
void get_line(int line) {
  for (int i = int(0); i < int(line + 1); i++) {
    tmp[i] = mult(fat[line], mult(inv(fat[i]), inv(fat[line - i])));
  }
}
int main() {
  fat[0] = 1;
  for (int i = int(1); i < int(MAX); i++) {
    fat[i] = mult(fat[i - 1], i);
  }
  scanf("%d", &n);
  for (int i = int(1); i < int(n + 1); i++) {
    scanf("%d", arr + i);
  }
  if (n % 4 == 0) {
    get_line((n / 4) * 2 - 1);
    for (int i = 1, k = 0; i <= n; i += 2, k++) {
      coef[i] = tmp[k];
      coef[i + 1] = (-coef[i] + MOD) % MOD;
    }
  } else if (n % 4 == 1) {
    get_line((n / 4) * 2);
    for (int i = 1, k = 0; i <= n; i += 2, k++) {
      coef[i] = tmp[k];
    }
  } else if (n % 4 == 2) {
    get_line((n / 4) * 2);
    for (int i = 1, k = 0; i <= n; i += 2, k++) {
      coef[i] = coef[i + 1] = tmp[k];
    }
  } else {
    get_line(((n - 1) / 4) * 2);
    for (int i = 1, k = 0; i <= n; i += 2, k++) {
      helper[i] = helper[i + 1] = tmp[k];
    }
    for (int i = int(1); i < int(n + 1); i++) {
      if (i & 1) {
        coef[i] = sub(helper[i], helper[i - 1]);
      } else {
        coef[i] = add(helper[i], helper[i - 1]);
      }
    }
  }
  int ans = 0;
  for (int i = int(1); i < int(n + 1); i++) {
    ans = add(ans, mult(arr[i], coef[i]));
  }
  printf("%d\n", ans);
  return 0;
}
