Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- const int mod = 1e9 + 7;
- signed main()
- {
- int n;
- cin >> n;
- vector<int> a(n);
- vector<int> s(n);
- for(int i = 0; i < n; i++){
- cin >> a[i];
- }
- s[n - 1] = 0;
- for(int i = (n - 2); i >= 0; i--){
- s[i] = s[i + 1] + a[i + 1];
- s[i] %= mod;
- }
- int ans = 0;
- for(int i = 0; i < n; i++){
- ans += (a[i] * s[i]);
- ans %= mod;
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement