fork download
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. #define endl "\n"
  4. using namespace std;
  5. const int MOD=1e9+7;
  6. int n,i,a[200001],t[200002]={},kq=0;
  7. signed main()
  8. {
  9. cin>>n;
  10. for(i=1;i<=n;i++) cin>>a[i];
  11. for(i=n;i>=1;i--) t[i]=(t[i+1]+a[i])%MOD;
  12. for(i=1;i<=n;i++)
  13. {
  14. kq=(kq+(a[i]*t[i+1])%MOD)%MOD;
  15. // cout<<kq<<endl;
  16. }
  17. cout<<kq;
  18. }
Success #stdin #stdout 0s 5316KB
stdin
3
1 2 3
stdout
11