/* -*- coding: utf-8 -*- * * 2938.cc: No.2938 Sigma Sigma Distance Distance Problem - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100; /* typedef */ /* global variables */ int as[MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); int sum = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) sum += abs(i - j) * abs(as[i] - as[j]); printf("%d\n", sum); return 0; }