提交时间:2024-08-20 16:53:21

运行 ID: 169737

#include<bits/stdc++.h> using namespace std; int a[1005],n,ans; int f(int x) { return (x-1)*(x-2)/2; } int main() { cin>>n; int t=f(n); for(int i=1;i<=n;i++) { cin>>a[i]; ans+=a[i]*t; } cout<<ans; return 0; }