#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unsigned long long arr[n];
  unsigned long long sum = 0;
  vector<unsigned long long> vct;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) vct.push_back((arr[n - 1] - arr[i]));
  for (auto u : vct) cout << u << " ";
  cout << "\n";
  for (int i = 1; i < n; i++) vct[i] += vct[i - 1];
  unsigned long long p = 0;
  for (unsigned long long i = 0; i < n - 1; i++) {
    p = p + vct[i];
    p = p % (1000000007);
  }
  cout << p;
  return 0;
}
