/*
https://ac.nowcoder.com/acm/contest/917/J
线段树维护区间的每个平方和
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+100;
LL tree1[N<<2],tree2[N<<2],lazy[N<<2];
void push_up(int k)
{
tree1[k]=tree1[k<<1]+tree1[k<<1|1];
tree2[k]=tree2[k<<1]+tree2[k<<1|1];
}
void build(int l,int r,int k)
{
lazy[k]=0;
if(l==r){
scanf("%lld",&tree1[k]);
tree2[k]=tree1[k]*tree1[k];
return;
}
int mid=(l+r)>>1;
build(l,mid,k<<1);
build(mid+1,r,k<<1|1);
push_up(k);
}
void push_down(int k,int len)
{
if(lazy[k]){
tree2[k<<1]+=(len-(len>>1))*lazy[k]*lazy[k]+2*tree1[k<<1]*lazy[k];
tree2[k<<1|1]+&#