Minimum Sum

AtCoder
IDagc005_b
Time2000ms
Memory256MB
Difficulty
One day, Snuke was given a permutation of length $N$, $a_1, a_2, ..., a_N$, from his friend. Find the following: ![image](https://atcoder.jp/img/agc005/520049e1a049bb9810b398b35d7dcb7f.png) ## Constraints * $1 ≦ N ≦ 200,000$ * $(a_1, a_2, ..., a_N)$ is a permutation of $(1, 2, ..., N)$. ## Input The input is given from Standard Input in the following format: $N$ $a_1$ $a_2$ $...$ $a_N$ [samples]
Samples
Input #1
3
2 1 3
Output #1
9
Input #2
4
1 3 2 4
Output #2
19
Input #3
8
5 4 8 1 2 6 7 3
Output #3
85
API Response (JSON)
{
  "problem": {
    "name": "Minimum Sum",
    "description": {
      "content": "One day, Snuke was given a permutation of length $N$, $a_1, a_2, ..., a_N$, from his friend. Find the following: ![image](https://atcoder.jp/img/agc005/520049e1a049bb9810b398b35d7dcb7f.png)",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc005_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "One day, Snuke was given a permutation of length $N$, $a_1, a_2, ..., a_N$, from his friend.\nFind the following:\n![image](https://atcoder.jp/img/agc005/520049e1a049bb9810b398b35d7dcb7f.png)\n\n## Constr...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments