6
58376259 643910770 5887448 757703054 544067926 902981667
 5
585325539 365329221 412106895 291882089 564718673
 7
941492387 72235422 449924898 783332532 378192988 592684636 147499872
 1
1
 16
985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082
 1
1000000000
 19
519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759
 17
458679894 912524637 347508634 863280107 226481104 787939275 48953130 553494227 458256339 673787326 353107999 298575751 436592642 233596921 957974470 254020999 707869688
 2
500000004 500000003
 4
702209411 496813081 673102149 561219907
 18
341796022 486073481 86513380 593942288 60606166 627385348 778725113 896678215 384223198 661124212 882144246 60135494 374392733 408166459 179944793 331468916 401182818 69503967
 3
524125987 923264237 374288891


676517605
 
974257995
 
328894634
 
1
 
347261016
 
1000000000
 
265109293
 
769845668
 
0
 
317278572
 
773499683
 
996365563

#include <bits/stdc++.h>
int combDP[] = {};
long long power(long long num, long long pow) {
  long long ans = 1;
  while (pow > 0) {
    if (pow % 2 == 1) {
      ans *= num;
      ans %= 1000000007LL;
    }
    pow /= 2;
    num *= num;
    num %= 1000000007LL;
  }
  return ans;
}
long long choose(int n, int k) {
  if (n == 0 || k == 0) return 1;
  if (combDP[k] != 0) return combDP[k];
  long long num = 1;
  for (int i = n; i > n - k; i--) {
    num *= i;
    num %= 1000000007LL;
  }
  long long denom = 1;
  for (int j = 1; j <= k; j++) {
    denom *= j;
    denom %= 1000000007LL;
  }
  long long inverse = power(denom, 1000000007LL - 2);
  long long ans = num * inverse;
  combDP[k] = ans % 1000000007LL;
  return ans % 1000000007LL;
}
int main(int argc, char *argv[]) {
  bool reversed = false;
  int n;
  scanf("%d", &n);
  long long nums[n];
  long long nums2[n - 1];
  for (int i = 0; i < n; i++) {
    scanf("%lld", &nums[i]);
  }
  if (n == 1) {
    printf("%lld\n", nums[0]);
    return 0;
  }
  if (n % 2 == 1) {
    for (int j = 0; j < n - 1; j += 2) {
      nums2[j] = nums[j] + nums[j + 1];
      nums2[j + 1] = nums[j + 1] - nums[j + 2];
    }
    for (int k = 0; k < n - 1; k++) {
      nums[k] = nums2[k];
    }
    n--;
  }
  if (n % 4 == 0) {
    reversed = true;
    for (int j = 0; j < n - 1; j += 2) {
      nums2[j] = nums[j] + nums[j + 1];
      nums2[j + 1] = nums[j + 1] - nums[j + 2];
    }
    for (int k = 0; k < n - 1; k++) {
      nums[k] = nums2[k];
    }
    n--;
    for (int j = 0; j < n - 1; j += 2) {
      nums2[j] = nums[j] - nums[j + 1];
      nums2[j + 1] = nums[j + 1] + nums[j + 2];
    }
    for (int k = 0; k < n - 1; k++) {
      nums[k] = nums2[k];
    }
    n--;
  }
  long long total = 0;
  for (int k = 0; k < n; k += 2) {
    if (reversed) {
      total += choose((n - 2) / 2, k / 2) * nums[k];
      total %= 1000000007LL;
      total -= choose((n - 2) / 2, k / 2) * nums[k + 1];
      total = total % 1000000007LL;
    } else {
      total += choose((n - 2) / 2, k / 2) * nums[k];
      total %= 1000000007LL;
      total += choose((n - 2) / 2, k / 2) * nums[k + 1];
      total %= 1000000007LL;
    }
  }
  if (total < 0) total += 1000000007LL;
  printf("%lld\n", total);
  return 0;
}
