#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define flc(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define vec vector<lint>
#define nep(x) next_permutation(all(x))
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=3e5+5;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//vector<int> bucket[MAX_N/1000];
constexpr lint MOD=1000000007;
//constexpr int MOD=998244353;
/*#include<atcoder/all>
using namespace atcoder;
typedef __int128_t llint;*/

int main(void){
    int N;
    cin >> N;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint ans=0;
    lint plus=1,minus=0;
    lint fib[N+1]={};
    fib[0]=1,fib[1]=1;
    rep(i,N-1) fib[i+2]=(fib[i+1]+fib[i])%MOD;
    rep(i,N){
        lint mul=(plus*fib[N-i]-minus*fib[N-i-1]+MOD*MOD)%MOD;
        ans=(ans+mul*A[i])%MOD;
        lint np=(plus+minus)%MOD;
        lint nm=(plus)%MOD;

        plus=np,minus=nm;
    }
    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) begin(v), end(v)
#define sz(v) v.size()
#define INF 1e17
#define EPSILON 1e-14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

bool collision_detection(ll a, ll b, ll c, ll d, ll e, ll f, ll g, ll h){
    pair<long double, long double> center1 = {(a+c)/2.0, (b+d)/2.0};
    pair<long double, long double> center2 = {(e+g)/2.0, (f+h)/2.0};
    long double x_dist = abs(center1.first - center2.first);
    long double y_dist = abs(center1.second - center2.second);
    if(x_dist >= (c-a)/2.0 + (g-e)/2.0){
        return false;
    }
    if(y_dist >= (d-b)/2.0 + (h-f)/2.0){
        return false;
    }
    return true;
}

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
           if(i*i != n){
               ret.push_back(n/i);
           }
       }
   }
   sort(all(ret));
   return ret;
}

int main()
{
    random_device rd;
    seed_seq seed = {rd()};
    mt19937 engine(seed);
    uniform_int_distribution<> dist(0, 9999);
    ll n;
    cin >> n;
    vector<ll> x(n), y(n), r(n);
    rep(i, n){
        cin >> x.at(i) >> y.at(i) >> r.at(i);
    }
    vector<tuple<ll, ll, ll, ll>> ads(n);
    rep(i, n){
        rep(j, r.at(i)){
            ll factor = pow(2,8);
            vector<ll> divisors = enum_div((r.at(i)-j)/factor);
            bool put = false;
            ll cnt = 0;
            for(ll div : divisors){
                if(cnt <= 8){
                    cnt++;
                    continue;
                }
                ll a = x.at(i);
                ll b = y.at(i);
                ll c = a + div;
                ll d = b + ((r.at(i)-j)/factor)/div;
                if(c > 10000 || d > 10000){
                    continue;
                }
                bool hit = false;
                rep(k, i){
                    if(collision_detection(a, b, c, d, get<0>(ads.at(k)), get<1>(ads.at(k)), get<2>(ads.at(k)), get<3>(ads.at(k)))){
                        hit = true;
                        break;
                    }
                }
                if(hit){
                    continue;
                }
                ads.at(i) = {a, b, c, d};
                put = true;
                break;
            }
            if(put){
                break;
            }
            if(j == r.at(i)-1){
                bool make = false;
                while(!make){
                    ll p = dist(engine);
                    ll q = dist(engine);
                    rep(k, i){
                        if(collision_detection(p, q, p+1, q+1, get<0>(ads.at(k)), get<1>(ads.at(k)), get<2>(ads.at(k)), get<3>(ads.at(k)))){
                            break;
                        }
                        if(k == i-1){
                            ads.at(i) = {p, q, p+1, q+1};
                            make = true;
                            break;
                        }
                    }
                }
            }
        }
        //cerr << i << endl;
    }
    rep(i, n){
        cout << get<0>(ads.at(i)) << " " << get<1>(ads.at(i)) << " " << get<2>(ads.at(i)) << " " << get<3>(ads.at(i)) << '\n';
    }
}