#include <bits/stdc++.h>
using namespace std;
long long int x, y;
long long int gcd(long long int a, long long int b) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  long long int gc = gcd(b % a, a);
  long long int temp;
  temp = x;
  x = y - (b / a) * temp;
  y = temp;
  return gc;
}
long long int a[200005 * 2];
long long int val[200005 * 2];
long long int b[5];
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  int i;
  int k;
  int second;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n % 2 == 0) {
    k = 0;
    second = 0;
    while (k < 3) {
      for (i = 1; i < n; i++) {
        if (second % 2 == 0) {
          a[i - 1] = a[i - 1] + a[i];
        } else {
          a[i - 1] = a[i - 1] - a[i];
        }
        second++;
        a[i - 1] += 1000000007;
        a[i - 1] %= 1000000007;
      }
      n--;
      k++;
    }
  }
  k = 0;
  second = n;
  while (second >= 1) {
    k += 2;
    second -= 4;
  }
  k -= 2;
  second += 4;
  val[0] = 1;
  for (i = 1; i <= k; i++) {
    val[i] = (val[i - 1] * (k - i + 1)) % 1000000007;
    gcd(1000000007, i);
    y = (y + 1000000007) % 1000000007;
    val[i] *= y;
    val[i] %= 1000000007;
  }
  int j;
  for (i = 0; i < second; i++) {
    for (j = 0; j <= k; j++) {
      b[i] += (val[j] * a[i + j * 2]);
      b[i] %= 1000000007;
    }
  }
  k = 0;
  while (second > 1) {
    for (i = 1; i < second; i++) {
      if (k % 2 == 0) {
        b[i - 1] = b[i - 1] + b[i];
      } else {
        b[i - 1] = b[i - 1] - b[i];
      }
      b[i - 1] = b[i - 1] + 1000000007;
      b[i - 1] %= 1000000007;
      k++;
    }
    second--;
  }
  cout << b[0];
}
