Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <stack>
- #include <cmath>
- #include <queue>
- #include <deque>
- #include <cassert>
- #include <string>
- #include <iomanip>
- using namespace std;
- #define INF 1000000000
- #define lint long long
- #define mp make_pair
- #define pb push_back
- #define MOD 1000000007
- int a[100005];
- int main()
- {
- int n;
- scanf("%d", &n);
- for (int i = 1; i <= n; ++i)
- {
- scanf("%d", &a[i]);
- }
- int ans = a[1];
- int sumOfProducts = a[1];
- for (int i = 2; i <= n; ++i)
- {
- ans = (ans + ans*1ll*a[i] + a[i] + sumOfProducts * 1ll * a[i]) % MOD;
- sumOfProducts = (sumOfProducts + sumOfProducts * 1ll * a[i] + a[i]) % MOD;
- }
- printf("%d", ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement