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;
- int a[n + 5];
- int sum = 0;
- for(int i = 1; i <= n; i++){
- cin >> a[i];
- sum += a[i];
- sum %= mod;
- }
- int ans = 0;
- for(int i = 1; i <= n; i++){
- sum = (sum + mod - a[i]) % mod;
- ans += (sum * a[i]);
- ans %= mod;
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement