Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- #include <iostream>
- #include <functional>
- #include <time.h>
- #include <cmath>
- #include <deque>
- using namespace std;
- #define ll long long
- #define mp make_pair
- #define pb push_back
- #define ld long double
- #pragma comment(linker, "/STACK:36777216")
- ll EPS = 1000000007;
- double PI = 3.14159265358979323846;
- const int MAXN = 1000010;
- ll abss(ll h)
- {
- if (h < 0)
- {
- return -h;
- }
- return h;
- }
- __int64 ceill(__int64 x, __int64 y)
- {
- if (x % y != 0)
- {
- return (x / y) + 1;
- }
- return x / y;
- }
- int n, m, k;
- ll a[MAXN];
- ll b[MAXN];
- char q[100];
- int main()
- {
- //freopen("strings.in", "r", stdin);
- //freopen("strings.out", "w", stdout);
- int n;
- cin >> n;
- int x;
- for (int i = 0; i < n; i++)
- {
- cin >> a[i];
- }
- b[0] = a[0];
- for (int i = 1; i < n; i++)
- {
- b[i] = b[i - 1] + a[i];
- }
- ll count = 0;
- for (int i = 0; i < n - 2; i++)
- {
- for (int j = i + 1; j < n - 1; j++)
- {
- count += (a[i] * a[j] * (b[n - 1] - b[j])) % EPS;
- count %= EPS;
- }
- }
- cout << count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement