Karen has just arrived at school, and she has a math test today!

<image>

The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.

There are n integers written on a row. Karen must alternately add and subtract each pair of adjacent integers, and write down the sums or differences on the next row. She must repeat this process on the values on the next row, and so on, until only one integer remains. The first operation should be addition.

Note that, if she ended the previous row by adding the integers, she should start the next row by subtracting, and vice versa.

The teachers will simply look at the last integer, and then if it is correct, Karen gets a perfect score, otherwise, she gets a zero for the test.

Karen has studied well for this test, but she is scared that she might make a mistake somewhere and it will cause her final answer to be wrong. If the process is followed, what number can she expect to be written on the last row?

Since this number can be quite large, output only the non-negative remainder after dividing it by 109 + 7.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 200000), the number of numbers written on the first row.

The next line contains n integers. Specifically, the i-th one among these is ai (1 ≤ ai ≤ 109), the i-th number on the first row.

Output

Output a single integer on a line by itself, the number on the final row after performing the process above.

Since this number can be quite large, print only the non-negative remainder after dividing it by 109 + 7.

Examples

Input

5
3 6 9 12 15


Output

36


Input

4
3 7 5 2


Output

1000000006

Note

In the first test case, the numbers written on the first row are 3, 6, 9, 12 and 15.

Karen performs the operations as follows:

<image>

The non-negative remainder after dividing the final number by 109 + 7 is still 36, so this is the correct output.

In the second test case, the numbers written on the first row are 3, 7, 5 and 2.

Karen performs the operations as follows:

<image>

The non-negative remainder after dividing the final number by 109 + 7 is 109 + 6, so this is the correct output.
#include <bits/stdc++.h>
using namespace std;
void display(vector<int> &a) {
  for (int z : a) cout << z << " ";
  cout << endl;
}
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
const int mod = (int)1e9 + 7;
const long long INF64 = 3e18;
void smxl(long long &a, long long b) {
  if (a < b) a = b;
}
void smnl(long long &a, long long b) {
  if (a > b) a = b;
}
void adsl(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
void misl(long long &a, long long b) {
  a -= b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
void smx(long long &a, long long b) {
  if (a < b) a = b;
}
void smn(long long &a, long long b) {
  if (a > b) a = b;
}
void ads(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
void mis(long long &a, long long b) {
  a -= b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long egcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long mbinp(long long a, long long b) {
  a %= mod;
  if (b == 0) return 1;
  long long ans = mbinp(a, b / 2);
  long long tmp = (ans * ans) % mod;
  if (b % 2) return ((tmp * a) % mod);
  return ((tmp) % mod);
}
long long binp(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = binp(a, b / 2);
  long long tmp = (ans * ans);
  if (b % 2) return ((tmp * a));
  return ((tmp));
}
long long C(int n, int m) {
  long long ret = 1;
  for (int i = 1; i <= m; i++) {
    ret *= (n - i + 1);
    ret /= i;
  }
  return ret;
}
long long overbinp(long long a, int b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      if (res < INF64 / a)
        res *= a;
      else
        return INF64;
    }
    if (b > 1) {
      if (a < INF64 / a)
        a *= a;
      else
        return INF64;
    }
    b >>= 1;
  }
  return res;
}
class DSU {
  vector<int> par;
  vector<int> siize;

 public:
  DSU(int n) {
    par.resize(n);
    siize.resize(n);
    for (int i = 0; i < n; i++) {
      par[i] = i;
      siize[i] = 1;
    }
  }

 public:
  int get(int x) { return (x == par[x] ? x : par[x] = get(par[x])); }

 public:
  void merge(int a, int b) {
    int x = get(a);
    int y = get(b);
    if (x == y) return;
    if (siize[x] < siize[y]) swap(x, y);
    par[y] = x;
    siize[x] += siize[y];
  }
};
class BinaryLift {
  vector<vector<int> > binlift;
  int n;

 public:
  BinaryLift(vector<int> rnk, vector<int> par) {
    n = (int)par.size();
    binlift.resize(n);
    for (int i = 0; i < n; i++) binlift[i].resize(20);
    for (int i = 0; i < n; i++) binlift[i][0] = par[i];
    for (int j = 1; j < 20; j++)
      for (int i = 0; i < n; i++) {
        if ((1 << j) < rnk[i])
          binlift[i][j] = binlift[binlift[i][j - 1]][j - 1];
        else
          binlift[i][j] = -1;
      }
  }

 public:
  int get_kth_ancestor(int x, int k) {
    int pt = x;
    for (int i = 19; i >= 0; i--) {
      if (pt == -1) exit(0);
      if (k & (1 << i)) pt = binlift[pt][i];
    }
    return pt;
  }

 public:
  int get_th_ancestor(int x, int k) {
    int pt = x;
    for (int i = 19; i >= 0; i--) {
      if (k & (1 << i)) pt = binlift[pt][i];
    }
    return pt;
  }
};
class SparseTable2D {
  vector<vector<vector<vector<int> > > > sparse;
  vector<vector<int> > inp;
  int m, n;

 private:
  int lg2(int x) {
    int out = 0;
    while ((1 << out) <= x) out++;
    return out - 1;
  }

 public:
  int rmin(int x1, int y1, int x2, int y2) {
    int lenx = x2 - x1 + 1;
    int lx = lg2(lenx) + 1;
    int leny = y2 - y1 + 1;
    int ly = lg2(leny) + 1;
    return min(
        min(sparse[lx][x1][ly][y1], sparse[lx][x1][ly][y2 + 1 - (1 << ly)]),
        min(sparse[lx][x2 + 1 - (1 << lx)][ly][y1],
            sparse[lx][x2 + 1 - (1 << lx)][ly][y2 + 1 - (1 << ly)]));
  }

 public:
  SparseTable2D(vector<vector<int> > input, string param) {
    n = input.size();
    m = input[0].size();
    inp = input;
    if (param == "min") prepromin();
  }

 private:
  void prepromin() {
    int lln, lm;
    lln = lg2(n) + 1;
    lm = lg2(m) + 1;
    sparse.resize(lln);
    for (int i = 0; i < lln; i++) sparse[i].resize(n);
    for (int i = 0; i < lln; i++)
      for (int j = 0; j < n; j++) sparse[i][j].resize(lm);
    for (int i = 0; i < lln; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < lm; k++) sparse[i][j][k].resize(m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) sparse[0][i][0][j] = inp[i][j];
      for (int j = 1; j < lm; j++)
        for (int k = 0; k + (1 << j) - 1 < m; k++)
          sparse[0][i][j][k] = min(sparse[0][i][j - 1][k],
                                   sparse[0][i][j - 1][k + (1 << (j - 1))]);
    }
    for (int i = 1; i < lln; i++)
      for (int j = 0; j + (1 << i) - 1 < n; j++)
        for (int k = 0; k < lm; k++)
          for (int h = 0; h < m; h++)
            sparse[i][j][k][h] = min(sparse[i - 1][j][k][h],
                                     sparse[i - 1][j + (1 << (i - 1))][k][h]);
  }
};
class SparseTable {
  vector<vector<long long> > sparse;
  int n;
  vector<int> input;

 private:
  int lg2(int x) {
    int out = 0;
    while ((1 << out) <= x) out++;
    return out - 1;
  }

 public:
  int rmaxpos(int left, int right) {
    int len = right - left + 1;
    int lg = lg2(len);
    return (input[sparse[left][lg]] > input[sparse[left + len - (1 << lg)][lg]]
                ? sparse[left][lg]
                : sparse[left + len - (1 << lg)][lg]);
  }

 public:
  int rmaxval(int left, int right) {
    int len = right - left + 1;
    int lg = lg2(len);
    return (input[sparse[left][lg]] > input[sparse[left + len - (1 << lg)][lg]]
                ? input[sparse[left][lg]]
                : input[sparse[left + len - (1 << lg)][lg]]);
  }

 public:
  int rminpos(int left, int right) {
    int len = right - left + 1;
    int lg = lg2(len);
    return (input[sparse[left][lg]] < input[sparse[left + len - (1 << lg)][lg]]
                ? sparse[left][lg]
                : sparse[left + len - (1 << lg)][lg]);
  }

 public:
  int rminval(int left, int right) {
    int len = right - left + 1;
    int lg = lg2(len);
    return (input[sparse[left][lg]] < input[sparse[left + len - (1 << lg)][lg]]
                ? input[sparse[left][lg]]
                : input[sparse[left + len - (1 << lg)][lg]]);
  }

 public:
  long long rsum(int left, int right) {
    long long ans = 0;
    int pos;
    while (left <= right) {
      for (int i = 19; i >= 0; i--)
        if ((1 << i) <= right - left + 1) {
          pos = i;
          break;
        }
      ans += sparse[left][pos];
      left = left + (1 << pos);
    }
    return ans;
  }

 public:
  SparseTable(vector<int> inp, string operation) {
    input = inp;
    n = inp.size();
    if (operation == "min")
      prepromin();
    else if (operation == "max")
      prepromax();
    else if (operation == "sum")
      preprosum();
  }

 private:
  void prepromin() {
    sparse.resize(n);
    int x = lg2(n) + 1;
    for (int i = 0; i < n; i++) sparse[i].resize(x);
    for (int i = 0; i < n; i++) sparse[i][0] = i;
    for (int j = 1; j < x; j++)
      for (int i = 0; i + (1 << (j)) - 1 < n; i++)
        sparse[i][j] =
            (input[sparse[i][j - 1]] < input[sparse[i + (1 << (j - 1))][j - 1]]
                 ? sparse[i][j - 1]
                 : sparse[i + (1 << (j - 1))][j - 1]);
  }
  void prepromax() {
    sparse.resize(n);
    int x = lg2(n) + 1;
    for (int i = 0; i < n; i++) sparse[i].resize(x);
    for (int i = 0; i < n; i++) sparse[i][0] = i;
    for (int j = 1; j < x; j++)
      for (int i = 0; i + (1 << (j)) - 1 < n; i++)
        sparse[i][j] =
            (input[sparse[i][j - 1]] > input[sparse[i + (1 << (j - 1))][j - 1]]
                 ? sparse[i][j - 1]
                 : sparse[i + (1 << (j - 1))][j - 1]);
  }
  void preprosum() {
    sparse.resize(n);
    int x = lg2(n) + 1;
    for (int i = 0; i < n; i++) sparse[i].resize(x);
    for (int i = 0; i < n; i++) sparse[i][0] = input[i];
    for (int j = 1; j < x; j++)
      for (int i = 0; i + (1 << (j)) - 1 < n; i++)
        sparse[i][j] = sparse[i][j - 1] + sparse[i + (1 << (j - 1))][j - 1];
  }
};
class Vector {
 public:
  pair<long long, long long> x;

 public:
  Vector(pair<long long, long long> a, pair<long long, long long> b) {
    x.first = b.first - a.first;
    x.second = b.second - a.second;
  }

 public:
  long double getMagnitude() {
    return sqrtl(x.first * x.first + x.second * x.second);
  }
};
class Line {
 public:
  pair<long long, long long> x, y;

 public:
  Line(pair<long long, long long> a, pair<long long, long long> b) {
    x = a;
    y = b;
  }

 private:
  long double dotProduct(Vector a, Vector b) {
    return a.x.first * b.x.first + a.x.second * b.x.second;
  }

 private:
  long double crossProduct(Vector a, Vector b) {
    return a.x.first * b.x.second - a.x.second * b.x.first;
  }

 private:
  long double magnitude(Vector a) { return a.getMagnitude(); }

 public:
  long double distanceToA(pair<long long, long long> c) {
    return dotProduct(Vector(x, y), Vector(x, c)) / magnitude(Vector(x, y));
  }

 public:
  long double orthogonalDistance(pair<long long, long long> c) {
    return crossProduct(Vector(x, y), Vector(x, c)) / magnitude(Vector(x, y));
  }

 public:
  pair<long double, long double> intersection(Line l) {
    pair<long double, long double> ans;
    ans.first = (long double)((x.first * y.second - x.second * y.first) *
                                  (l.x.first - l.y.first) -
                              (x.first - y.first) * (l.x.first * l.y.second -
                                                     l.x.second * l.y.first)) /
                ((x.first - y.first) * (l.x.second - l.y.second) -
                 (x.second - y.second) * (l.x.first - l.y.first));
    ans.second =
        (long double)((x.first * y.second - x.second * y.first) *
                          (l.x.second - l.y.second) -
                      (x.second - y.second) *
                          (l.x.first * l.y.second - l.x.second * l.y.first)) /
        ((x.first - y.first) * (l.x.second - l.y.second) -
         (x.second - y.second) * (l.x.first - l.y.first));
    return ans;
  }
};
class PruferCode {
  vector<int> code;
  vector<pair<int, int> > edges;

 public:
  PruferCode(vector<int> cc) {
    code = cc;
    findEdges();
  }

 private:
  void findEdges() {
    map<int, int> mp;
    set<int> has;
    set<int> wait;
    for (int z : code) {
      mp[z]++;
      has.insert(z);
    }
    for (int i = 0; i < code.size() + 2; i++)
      if (!has.count(i)) wait.insert(i);
    for (int i = 0; i < code.size(); i++) {
      int now = *wait.begin();
      edges.push_back(make_pair(now, code[i]));
      mp[now]++;
      mp[code[i]]--;
      if (mp[code[i]] == 0) {
        has.erase(code[i]);
        wait.insert(code[i]);
      }
      wait.erase(now);
    }
    assert(wait.size() == 2);
    edges.push_back(make_pair(*wait.begin(), *wait.rbegin()));
  }

 public:
  vector<pair<int, int> > getEdges() { return edges; }
};
class Segment {
  pair<long long, long long> x, y;

 public:
  Segment(pair<long long, long long> a, pair<long long, long long> b) {
    x = a;
    y = b;
  }

 private:
  long double dotProduct(Vector a, Vector b) {
    return a.x.first * b.x.first + a.x.second * b.x.second;
  }

 private:
  long double crossProduct(Vector a, Vector b) {
    return a.x.first * b.x.second - a.x.second * b.x.first;
  }

 private:
  long double magnitude(Vector a) { return a.getMagnitude(); }

 public:
  long double distanceToA(pair<long long, long long> c) {
    return dotProduct(Vector(x, y), Vector(x, c)) / magnitude(Vector(x, y));
  }

 public:
  long double distanceToSegment(pair<long long, long long> c) {
    if (distanceToA(c) >= 0 && distanceToA(c) <= magnitude(Vector(x, y)))
      return crossProduct(Vector(x, y), Vector(x, c)) / magnitude(Vector(x, y));
    else
      return min(magnitude(Vector(x, c)), magnitude(Vector(y, c)));
  }
};
class SegmentTree {
  int len;
  vector<long long> all;
  vector<long long> seg;
  vector<long long> lazy;

 public:
  SegmentTree(vector<long long> inp, char op) {
    len = inp.size();
    all = inp;
    seg.resize(4 * len);
    lazy.resize(4 * len);
    build(1, 0, len - 1);
  }
  void build(int id, int l, int r) {
    if (l == r) {
      seg[id] = all[l];
      return;
    }
    int mid = (l + r) / 2;
    build(2 * id, l, mid);
    build(2 * id + 1, mid + 1, r);
    seg[id] = seg[2 * id] + seg[2 * id + 1];
  }
  void update(int id, int l, int r, int sl, int sr, long long val) {
    if (lazy[id] != -1) {
      seg[id] = lazy[id] * (r - l + 1);
      if (l != r) {
        lazy[2 * id] = lazy[id];
        lazy[2 * id + 1] = lazy[id];
      }
      lazy[id] = -1;
    }
    if (r < sl || sr < l) return;
    if (sl <= l && sr >= r) {
      seg[id] = val * (r - l + 1);
      if (l != r) {
        lazy[2 * id] = val;
        lazy[2 * id + 1] = val;
      }
      return;
    }
    int mid = (l + r) / 2;
    update(2 * id, l, mid, sl, sr, val);
    update(2 * id + 1, mid + 1, r, sl, sr, val);
    seg[id] = seg[2 * id] + seg[2 * id + 1];
  }
  long long query(int id, int l, int r, int sl, int sr) {
    if (lazy[id] != -1) {
      seg[id] = lazy[id] * (r - l + 1);
      if (r != l) {
        lazy[2 * id] = lazy[id];
        lazy[2 * id + 1] = lazy[id];
      }
      lazy[id] = -1;
    }
    if (r < sl || sr < l) return 0;
    if (sl <= l && sr >= r) return seg[id];
    int mid = (l + r) / 2;
    return (query(2 * id, l, mid, sl, sr) +
            query(2 * id + 1, mid + 1, r, sl, sr));
  }
};
class HopcroftKarp {
  vector<int> matched;
  vector<vector<pair<int, int> > > adj;
  int left;
  int right;

 public:
  HopcroftKarp(vector<vector<pair<int, int> > > inp, int l, int r) {
    adj = inp;
    left = l;
    matched.resize(l);
    for (int i = 0; i < l; i++) matched[i] = -1;
    right = r;
  }

 public:
  vector<int> match() {
    bool cont = true;
    set<int> lfree, rfree;
    for (int i = 0; i < left; i++) lfree.insert(i);
    for (int i = left; i < left + right; i++) rfree.insert(i);
    vector<bool> yet(left, 0);
    for (int i = 0; i < left; i++)
      for (int j = 0; j < adj[i].size(); j++)
        if (adj[i][j].second == 1 && rfree.count(adj[i][j].first) && !yet[i]) {
          yet[i] = true;
          matched[i] = adj[i][j].first;
          adj[i][j].second = 2;
          for (int x = 0; x < adj[adj[i][j].first].size(); x++)
            if (adj[adj[i][j].first][x].first == i)
              adj[adj[i][j].first][x].second = 2;
          rfree.erase(adj[i][j].first);
          lfree.erase(i);
        }
    while (cont) {
      vector<int> par(left + right, -1);
      queue<pair<int, int> > kyou;
      for (int z : lfree) kyou.push(make_pair(z, 0));
      int update = -1;
      vector<int> vis(left + right, 0);
      while (kyou.size()) {
        pair<int, int> frt = kyou.front();
        kyou.pop();
        if (rfree.count(frt.first)) {
          update = frt.first;
          break;
        }
        if (frt.second == 0) {
          for (pair<int, int> z : adj[frt.first]) {
            if (z.second == 1 && !vis[z.first]) {
              par[z.first] = frt.first;
              vis[z.first] = 1;
              kyou.push(make_pair(z.first, 1));
            }
          }
        } else {
          for (pair<int, int> z : adj[frt.first]) {
            if (z.second == 2 && !vis[z.first]) {
              par[z.first] = frt.first;
              vis[z.first] = 1;
              kyou.push(make_pair(z.first, 0));
            }
          }
        }
      }
      int x = update;
      int cnt = 0;
      while (x != -1 && par[x] != -1) {
        for (int i = 0; i < adj[x].size(); i++)
          if (adj[x][i].first == par[x]) {
            adj[x][i].second = (cnt == 0 ? 2 : 1);
            if (cnt == 0) {
              matched[par[x]] = x;
              rfree.erase(x);
              lfree.erase(par[x]);
            }
          }
        for (int i = 0; i < adj[par[x]].size(); i++)
          if (adj[par[x]][i].first == x)
            adj[par[x]][i].second = (cnt == 0 ? 2 : 1);
        cnt++;
        cnt %= 2;
        x = par[x];
      }
      if (update == -1) cont = false;
    }
    return matched;
  }
};
class Triangle {
  pair<long long, long long> x, y, z;

 public:
  Triangle(pair<long long, long long> a, pair<long long, long long> b,
           pair<long long, long long> c) {
    x = a;
    y = b;
    z = c;
  }

 private:
  long double crossProduct(Vector a, Vector b) {
    return a.x.first * b.x.second - a.x.second * b.x.first;
  }

 public:
  long double perimeter() {
    long double s1, s2, s3;
    s1 = Vector(x, y).getMagnitude();
    s2 = Vector(y, z).getMagnitude();
    s3 = Vector(x, z).getMagnitude();
    return s1 + s2 + s3;
  }

 public:
  long double area() { return abs(crossProduct(Vector(x, y), Vector(x, z))); }
};
class SuffixArray {
  vector<int> order;
  vector<int> lcp;
  string str;

 public:
  SuffixArray(string in) {
    str = in;
    str += '$';
    order.resize(str.length());
    lcp.resize(str.length());
    compute();
  }
  void compute() {
    vector<pair<char, int> > a;
    vector<int> equi(order.size());
    vector<int> bij(order.size());
    for (int i = 0; i < str.length(); i++) a.push_back(make_pair(str[i], i));
    sort(a.begin(), a.end());
    for (int i = 0; i < str.length(); i++) order[i] = a[i].second;
    equi[order[0]] = 0;
    int r = 0;
    for (int i = 1; i < str.length(); i++) {
      if (a[i].first == a[i - 1].first)
        equi[order[i]] = r;
      else
        equi[order[i]] = ++r;
    }
    int k = 0;
    while ((1 << k) < str.length()) {
      vector<pair<pair<int, int>, int> > a(str.length());
      for (int i = 0; i < str.length(); i++)
        a[i] = make_pair(
            make_pair(equi[i], equi[(i + (1 << k)) % (str.length())]), i);
      sort(a.begin(), a.end());
      for (int i = 0; i < str.length(); i++) {
        order[i] = a[i].second;
        bij[order[i]] = i;
      }
      int r = 0;
      equi[order[0]] = 0;
      for (int i = 1; i < str.length(); i++) {
        if (a[i].first == a[i - 1].first)
          equi[order[i]] = r;
        else
          equi[order[i]] = ++r;
      }
      k++;
    }
    k = 0;
    for (int i = 0; i < str.length() - 1; i++) {
      int p = bij[i];
      int j = order[p - 1];
      while (i + k < str.length() && j + k < str.length() &&
             str[i + k] == str[j + k])
        k++;
      lcp[p] = k;
      k = max(k - 1, 0);
    }
  }

 public:
  int count(string ptr) {
    int low = 0;
    int hi = str.length() - 1;
    int res1, res2;
    res1 = 0;
    res2 = 1e9;
    while (low <= hi) {
      int mid = (low + hi) / 2;
      bool gr = false;
      int i = 0;
      for (i; i < min(ptr.length(), str.length() - order[mid]); i++) {
        if (ptr[i] != str[order[mid] + i]) {
          if (ptr[i] > str[order[mid] + i]) gr = true;
          break;
        }
      }
      if (i == ptr.length()) {
        res2 = min(res2, mid);
        hi = mid - 1;
      } else if (!gr)
        hi = mid - 1;
      else
        low = mid + 1;
    }
    low = 0;
    hi = str.length() - 1;
    while (low <= hi) {
      int mid = (low + hi) / 2;
      bool gr = false;
      int i = 0;
      for (i; i < min(ptr.length(), str.length() - order[mid] + 1); i++) {
        if (ptr[i] != str[order[mid] + i]) {
          if (ptr[i] > str[order[mid] + i]) gr = true;
          break;
        }
      }
      if (i == ptr.length()) {
        res1 = max(res1, mid);
        low = mid + 1;
      } else if (!gr)
        hi = mid - 1;
      else
        low = mid + 1;
    }
    if (res2 == 1e9) return 0;
    return (res1 - res2 + 1);
  }

 public:
  vector<int> get() { return order; }

 public:
  vector<int> getLcp() { return lcp; }

 public:
  long long diffSubstrings() {
    long long out = 0;
    for (int i = 1; i < str.length(); i++)
      out += str.length() - order[i] - lcp[i] - 1;
    return out;
  }
};
string longestCommonSubstring(string a, string b) {
  int len = 0;
  string res = a + '%' + b;
  SuffixArray sf = SuffixArray(res);
  vector<int> order = sf.get();
  vector<int> lcp = sf.getLcp();
  vector<int> col(order.size());
  for (int i = 0; i < order.size(); i++) {
    if (order[i] < a.length())
      col[order[i]] = 1;
    else if (order[i] > a.length())
      col[order[i]] = 2;
  }
  int pos = -1;
  for (int i = 1; i < order.size(); i++)
    if (col[order[i]] + col[order[i - 1]] == 3) {
      if (lcp[i] > len) {
        len = max(len, lcp[i]);
        pos = (col[order[i]] == 1 ? order[i] : order[i - 1]);
      }
    }
  return a.substr(pos, len);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int nax = 3e5 + 10;
  vector<long long> fac(nax, 1);
  vector<long long> inv(nax, 1);
  for (int i = 2; i < nax; i++) fac[i] = ((fac[i - 1]) * i) % mod;
  for (int i = 0; i < nax; i++) inv[i] = mbinp(fac[i], mod - 2);
  vector<int> all(n);
  for (int i = 0; i < n; i++) cin >> all[i];
  if (n == 1) {
    cout << all[0];
    return 0;
  }
  if (n % 2) {
    vector<int> tmp;
    for (int i = 0; i < n - 1; i++) {
      if (i % 2)
        tmp.push_back(all[i] - all[i + 1]);
      else
        tmp.push_back(all[i] + all[i + 1]);
    }
    all = tmp;
  }
  vector<int> t1, t2;
  for (int i = 0; i < all.size(); i += 2) t1.push_back(all[i]);
  for (int i = 1; i < all.size(); i += 2) t2.push_back(all[i]);
  long long ans = 0;
  for (int i = 0; i < t1.size(); i++) {
    ans += ((((fac[t1.size() - 1] * inv[i]) % mod) * inv[t1.size() - 1 - i]) %
            mod) *
           t1[i];
    ans %= mod;
  }
  long long ans1 = 0;
  for (int i = 0; i < t2.size(); i++) {
    ans1 += ((((fac[t2.size() - 1] * inv[i]) % mod) * inv[t2.size() - 1 - i]) %
             mod) *
            t2[i];
    ans1 %= mod;
  }
  if (all.size() % 4 == 0)
    cout << (ans - ans1 + mod) % mod;
  else
    cout << (ans + ans1 + mod) % mod;
}
