/* -*- coding: utf-8 -*- * * 2036.cc: No.2036 Max Middle - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; enum { LT, GT }; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], es[MAX_N]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); n--; for (int i = 0; i < n; i++) es[i] = (as[i] < as[i + 1]) ? LT : GT; ll sum = 0; int ln = 0; for (int i = 0; i < n; i++) { if (es[i] == LT) ln++; else sum += ln; } printf("%lld\n", sum); return 0; }