#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> x(n);
  int* arr = new int[n]{};
  int ans(0);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 1; i < n; i++) {
    arr[i - 1] = x[n - 1] - x[n - 1 - i];
  }
  for (int i = 0; i < n - 2; i++) {
    ans = (ans + arr[i] * (unsigned int)pow(2, n - 3)) % 1000000007;
    cout << (unsigned int)pow(2, n - 3) << endl;
    cout << arr[i] * (unsigned int)pow(2, n - 3) << endl;
  }
  ans = (ans + arr[n - 2] * (unsigned int)pow(2, n - 2)) % 1000000007;
  cout << ans;
  return 0;
}
