#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
template <class T> void chmin(T &a, const T &b) {
    if (a > b) a = b;
}
template <class T> void chmax(T &a, const T &b) {
    if (a < b) a = b;
}

void add(ll &a, ll b) {
    a = (a + b) % MOD;
}

void mul(ll &a, ll b) {
    a %= MOD;
    b %= MOD;
    a = a * b % MOD;
}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> num_dp(2, 0);
    num_dp[0] = 1;
    vector<ll> sum_dp(2, 0);
    sum_dp[0] = A[0];
    for (int i = 1; i < N; i++) {
        vector<ll> nex_num_dp(2, 0);
        vector<ll> nex_sum_dp(2, 0);
        {
            add(nex_num_dp[1], num_dp[0]);
            add(nex_num_dp[0], num_dp[0]);
            add(nex_num_dp[0], num_dp[1]);
        }
        {
            add(nex_sum_dp[1], ((sum_dp[0] - A[i] * num_dp[0] % MOD) % MOD + MOD) % MOD);
            add(nex_sum_dp[0], ((sum_dp[0] + A[i] * num_dp[0] % MOD) % MOD + MOD) % MOD);
            add(nex_sum_dp[0], ((sum_dp[1] + A[i] * num_dp[1] % MOD) % MOD + MOD) % MOD);
        }
        swap(nex_num_dp, num_dp);
        swap(nex_sum_dp, sum_dp);
    }

    ll ans = 0;
    add(ans, sum_dp[0]);
    add(ans, sum_dp[1]);
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int mod = 998244353;

ll binpow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            (res *= a) %= mod;
        }
        p >>= 1;
        (a *= a) %= mod;
    }
    return res;
}

void solve() {
    ll n;
    cin >> n;
    ll g = 1;
    for (ll i = 2; i <= n; i++) {
        g = g * i / __gcd(i, g);
    }
    cout << g + 1 << '\n';
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin >> T;
    for (int tc = 1; tc <= T; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
    return 0;
}