text: InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class D421 { InputStream is; PrintWriter out; int n; long a[]; private boolean oj = System.getProperty("ONLINE_JUDGE") != null; void solve() { int n = ni(); int p[] = new int[n + 1]; for (int i = 1; i <= n; i++) { p[i] = ni(); } int a[] = new int[n + 1]; long s1 = 0; long s2 = 0; int count = 0; for (int i = 1; i <= n; i++) { if (p[i] > i) { a[p[i] - i]++; s1 += p[i] - i; count++; } else { s2 += i - p[i]; } } int shift = 1; int ind = 0; long min = s1 + s2; for (int i = n; i > 1; i--) { s1 -= count; s2 += n - count - 1; s2 -= n - p[i]; s1 += p[i] - 1; if (shift + p[i] - 1 <= n) { a[shift + p[i] - 1]++; } count = count - a[shift]; count++; if (s1 + s2 < min) { min = s1 + s2; ind = shift; } shift++; } out.println(min + " " + ind); } void run() throws Exception { String INPUT = "C:\\Users\\Admin\\Desktop\\input.txt"; is = oj ?System.in : new FileInputStream(INPUT); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(System.currentTimeMillis() - s + "ms"); } public static void main(String[] args) throws Exception { new Thread(null, new Runnable() { public void run() { try { new D421().run(); } catch (Exception e) { e.printStackTrace(); } } }, "1", 1 << 26).start(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0, ptrbuf = 0; private int readByte() { if (lenbuf == -1) throw new InputMismatchException(); if (ptrbuf >= lenbuf) { ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while ((b = readByte()) != -1 && isSpaceChar(b)) ; return b; } private double nd() { return Double.