#pragma GCC optimize ("Ofast") #pragma GCC target ("sse4") #include #include #include using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair pii; typedef pair pll; #define fi first #define se second #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define all(x) begin(x),end(x) #define forn(i, n) for (int i = 0; i < n; ++i) #define rforn(i, n) for (int i = n - 1; i >= 0; --i) const int N = 2e5 + 5, M = 1e9 + 7; // 998244353 const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0}; const ll INF = 1e18 + 10LL; const ld PI = 4.0 * atan((ld) 1.0), EPS = 1e-6; const char nl = '\n'; template< typename T > inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template< typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; } template void ckmin(T& a, T b) {a = min(a, b);} template void ckmax(T& a, T b) {a = max(a, b);} template using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>; string YN(bool x) { return x ? "YES" : "NO"; } void solve(int tcn) { int n; cin >> n; vector a(n); forn(i, n) cin >> a[i]; while (a.size() > 1) { vector b(a.size() - 1); forn(i, a.size() - 1) { b[i] = a[i] + a[i + 1]; b[i] %= M; } a = b; } cout << a[0] % M << nl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for (int i = 1; i <= t; ++i) { solve(i); } return 0; }