{"problem":{"name":"Increment and Swap","description":{"content":"We have a sequence $A$ of length $N$. On this sequence, we can perform the following two kinds of operations: *   Swap two adjacent elements.      *   Select one element, and increment it by $1$.    ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"cf17_exhibition_b"},"statements":[{"statement_type":"Markdown","content":"We have a sequence $A$ of length $N$.\nOn this sequence, we can perform the following two kinds of operations:\n\n*   Swap two adjacent elements.\n    \n*   Select one element, and increment it by $1$.\n    \n\nWe will repeatedly perform these operations so that $A$ will be a non-decreasing sequence. Find the minimum required number of operations.\n\n## Constraints\n\n*   $1 ≤ N ≤ 200000$\n*   $1 ≤ A_i ≤ 10^9$\n*   $A_i$ is an integer.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$A_1$\n$A_2$\n$:$\n$A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"cf17_exhibition_b","tags":[],"sample_group":[["5\n4\n1\n8\n8\n7","2\n\nWe can turn $A$ into a non-decreasing sequence in two operations:\n\n*   Initially, $A = {4, 1, 8, 8, 7}$.\n*   Swap the first two elements. Now, $A = {1, 4, 8, 8, 7}$.\n*   Increment the last element by $1$. Now, $A = {1, 4, 8, 8, 8}$."],["20\n8\n2\n9\n7\n4\n6\n7\n9\n7\n4\n7\n4\n4\n3\n6\n2\n3\n4\n4\n9","62"]],"created_at":"2026-03-03 11:01:14"}}