import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Stanislav Pak
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
		int n = in.readInt();
		int[] p = new int[n];
		for (int i = 0; i < n; ++i) {
			p[i] = in.readInt();
		}
		int mn = (int) 1e8;
		int cnt = 0;
		int invCount = 0;
		for (int i = 0; i < n; ++i) {
			FenwickTree t = new FenwickTree(n);
			for (int j = i + 1; j < n; ++j) {
				if (p[i] > p[j]) ++invCount;
				int diff = getDiff(t, p[i], p[j], n);
				if (p[i] > p[j]) --diff;
				else ++diff;
				if (diff < mn) {
					mn = diff;
					cnt = 1;
				} else if (diff == mn) {
					++cnt;
				}
				t.add(p[j], 1);
			}
		}
		out.printLine(invCount + mn, cnt);
    }

	private int getDiff(FenwickTree t, int i, int j, int n) {
		long ret = t.get(i + 1, n - 1) - t.get(0, i - 1);
		ret += t.get(0, j - 1) - t.get(j + 1, n - 1);
		return (int) ret;
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

}

class FenwickTree {
	private final long[] value;

	public FenwickTree(int size) {
		value = new long[size];
	}

	public long get(int from, int to) {
		return get(to) - get(from - 1);
	}

	private long get(int to) {
		to = Math.min(to, value.length - 1);
		long result = 0;
		while (to >= 0) {
			result += value[to];
			to = (to & (to + 1)) - 1;
		}
		return result;
	}

	public void add(int at, long value) {
		while (at < this.value.length) {
			this.value[at] += value;
			at = at | (at + 1);
		}
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;
        Scanner in = new Scanner();
        // out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt() + 1;
        }

        int total = 0;
        FT tree = new FT(n + 2);
        for (int i = 0; i < n; i++) {
            total += tree.get(n + 1) - tree.get(data[i]);
            tree.update(data[i], 1);
        }
        long result = total;
        int c = 0;
        //System.out.println(total);
        for (int i = 0; i < n; i++) {
            FT other = new FT(n + 2);
            for (int j = n - 1; j > i; j--) {
                long x = tree.get(n + 1) - tree.get(data[j]) - (other.get(n + 1) - other.get(data[j])) ;//Those greater than data[j]
                long y = tree.get(data[j]) - other.get(data[j]) - 1;//Those less than data[j];
                long z = tree.get(n + 1) - tree.get(data[i]) - (other.get(n + 1) - other.get(data[i]));//Those greater than data[i]
                long k =  tree.get(data[i]) - other.get(data[i]) - 1;//Those less than data[i]
                if(data[i] > data[j]){
                    x--;
                }else{
                    y--;
                }
                long tmp = total - x + y + z - k;
               // System.out.println(x + " " + y + " " +z + " " + k + " "+ i + " " + j + ": " + tmp);
                if (tmp < result) {
                    result = tmp;
                    c = 1;
                } else if (tmp == result) {
                    c++;
                }
                other.update(data[j],1);
            }
            tree.update(data[i],-1);
        }
        out.println(result + " " + c);

        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;
        Scanner in = new Scanner();
        // out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        int[][] less = new int[n][n];
        int[][] greater = new int[n][n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j > 0) {
                    greater[i][j] += greater[i][j - 1];
                }
                if (data[j] > data[i]) {
                    greater[i][j]++;
                }
            }
            total += greater[i][i];
          //  System.out.println(greater[i][i]);
            for (int j = n - 1; j >= 0; j--) {
                if (j + 1 < n) {
                    less[i][j] += less[i][j + 1];
                }
                if (data[j] < data[i]) {
                    less[i][j]++;
                }
            }
        }
        int result = total;
        int c = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int x = less[i][i] - (j + 1 < n ? less[i][j + 1] : 0);
                int y = less[j][i] - less[j][j] ;
                int z = greater[j][j] - greater[j][i];
                int k = greater[i][j] - greater[i][i];
                int tmp = total - x + y - z + k;
                //System.out.println(x + " " + y + " " + i + " " + j);
                if (tmp < result) {
                    result = tmp;
                    c = 1;
                } else if (tmp == result) {
                    c++;
                }
            }
        }
        out.println(result + " " + c);

        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 1000000007;
    static int x = 0, y = 0;
    static boolean start;
    public static long[][] dp, c;
    public static int[] X = {0, 1, 0, -1};
    public static int[] Y = {1, 0, -1, 0};

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;
        Scanner in = new Scanner();
        // out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt();
        }
        int[][] less = new int[n][n];
        int[][] greater = new int[n][n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j > 0) {
                    greater[i][j] += greater[i][j - 1];
                }
                if (data[j] > data[i]) {
                    greater[i][j]++;
                }
            }
            total += greater[i][i];
          //  System.out.println(greater[i][i]);
            for (int j = n - 1; j >= 0; j--) {
                if (j + 1 < n) {
                    less[i][j] += less[i][j + 1];
                }
                if (data[j] < data[i]) {
                    less[i][j]++;
                }
            }
        }
        int result = total;
        int c = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int x = less[i][i] - (j + 1 < n ? less[i][j + 1] : 0);
                int y = less[j][i] - less[j][j] ;
                int z = greater[j][j] - greater[j][i];
                int k = greater[i][j] - greater[i][i];
                int tmp = total - x + y - z + k;
                //System.out.println(x + " " + y + " " + i + " " + j);
                if (tmp < result) {
                    result = tmp;
                    c = 1;
                } else if (tmp == result) {
                    c++;
                }
            }
        }
        out.println(result + " " + c);

        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class D {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;
        Scanner in = new Scanner();
        // out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] data = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = in.nextInt() + 1;
        }

        int total = 0;
        FT tree = new FT(n + 2);
        for (int i = 0; i < n; i++) {
            total += tree.get(n + 1) - tree.get(data[i]);
            tree.update(data[i], 1);
        }
        long result = total;
        int c = 0;
        //System.out.println(total);
        for (int i = 0; i < n; i++) {
            FT other = new FT(n + 2);
            for (int j = n - 1; j >=0; j--) {
                long x = tree.get(n + 1) - tree.get(data[j]) - (other.get(n + 1) - other.get(data[j])) ;//Those greater than data[j]
                long y = tree.get(data[j]) - other.get(data[j]);//Those less than data[j];
                long z = tree.get(n + 1) - tree.get(data[i]) - (other.get(n + 1) - other.get(data[i]));
                long k =  tree.get(data[i]) - other.get(data[i]) - 1;
                long tmp = total - x + y + z - k;
             //   System.out.println(x + " " + y + " " +z + " " + k + " "+ i + " " + j);
                if (tmp < result) {
                    result = tmp;
                    c = 1;
                } else if (tmp == result) {
                    c++;
                }
                other.update(data[i],1);
            }
            tree.update(data[i],-1);
        }
        out.println(result + " " + c);

        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


/**
 * Created by ckboss on 14-9-4.
 */

import java.util.*;

public class InsertionSort {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n + 10];
        int[][] dp = new int[n + 10][n + 10];

        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < n; j++) {
                int t = 0;
                if (a[i] < j) t = 1;
                dp[i][j] = dp[i - 1][j] + t;
            }

        }

        int ISN = 0;
        for (int i = 1; i <= n; i++)
            ISN += i - 1 - dp[i][a[i]];

        int MinISN = (1 << 30);
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (a[i] > a[j]) {
                    int len = j - i - 1;
                    int p = dp[j - 1][a[i]] - dp[i][a[i]];
                    int q = dp[j - 1][a[j]] - dp[i][a[j]];
                    int temp = ISN + 2 * (q - p) - 1;

                    if (temp < MinISN)
                        MinISN = temp;
                }
            }
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (a[i] > a[j]) {
                    int len = j - i - 1;
                    int p = dp[j - 1][a[i]] - dp[i][a[i]];
                    int q = dp[j - 1][a[j]] - dp[i][a[j]];
                    int temp = ISN + 2 * (q - p) - 1;

                    if (temp == MinISN)
                        ans++;
                }
            }
        }

        System.out.println(MinISN + " " + ans);
    }
}
// 1504003518584


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x362C2
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken())+1;
         int max = 0;
         for(int a=0; a < N; a++)
            for(int b=a+1; b < N; b++)
               if(arr[a] > arr[b])
                  max++;
         int res = max;
         int freq = 1;
         for(int a=0; a < N; a++)
         {
            FenwickTree bit = new FenwickTree(N+1);
            for(int b=a+1; b < N; b++)
            {
               if(arr[a] > arr[b])
               {
                  //swap
                  int val = max-1;
                  val += bit.find(arr[a]+1, N)+bit.find(arr[b]-1);
                  val -= bit.find(arr[b]+1, N)+bit.find(arr[a]-1);
                  if(val < res)
                  {
                     res = val;
                     freq = 1;
                  }
                  else if(val == res)
                     freq++;
               }
               bit.add(arr[b], 1);
            }
         }
         System.out.println(res+" "+freq);
      }
   }
   class FenwickTree
   {
      //1 indexed
      public int[] tree;
      public int size;

      public FenwickTree(int size)
      {
         this.size = size;
         tree = new int[size+5];
      }
      public void add(int i, int v)
      {
         while(i <= size)
         {
            tree[i] += v;
            i += i&-i;
         }
      }
      public int find(int i)
      {
         int res = 0;
         while(i >= 1)
         {
            res += tree[i];
            i -= i&-i;
         }
         return res;
      }
      public int find(int l, int r)
      {
         return find(r)-find(l-1);
      }
   }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Task {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA s = new TaskA();
		s.solve(in, out);
		out.close();
	}
}

class TaskA {
	public void solve(InputReader in, PrintWriter out) {
		int n=in.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();

		int[][] dp=new int[n][n];
		for(int i=0;i<n;i++){
			dp[0][i]=a[0]<i?1:0;
		}
		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				dp[i][j]=dp[i-1][j]+(a[i]<j?1:0);
			}
		}

		int max=0;
		int left,right;
		int cnt=0;

		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]<a[j])
					continue;
				int tmp=dp[j-1][a[i]]-dp[i][a[i]]+dp[i][a[j]]-dp[j-1][a[j]];
				if(tmp>max){
					max=tmp;
					left=i;right=j;
					cnt=1;
				}else if(tmp==max){
					cnt++;
				}
			}
		}

		int ans=0;
		for(int i=1;i<n;i++){
			ans+=(i-dp[i][a[i]]);
		}

		out.println((ans-max*2-1)+" "+cnt);
	}

	public void swap(int[] a,int i,int j){
		int tmp=a[i];
		a[i]=a[j];
		a[j]=tmp;
	}

}

class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Task {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA s = new TaskA();
		s.solve(in, out);
		out.close();
	}
}

class TaskA {
	public void solve(InputReader in, PrintWriter out) {
		int n=in.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();

		int min=Integer.MAX_VALUE;
		int cnt=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				swap(a,i,j);
				int tmp=0;
				for(int t=n-1;t>=0;t--){
					for(int k=t-1;k>=0;k--){
						if(a[t]<a[k]){
							tmp++;
						}
					}
				}
				if(tmp==min){
					cnt++;
				}else if(tmp<min){
					min=tmp;
					cnt=1;
				}
				swap(a,i,j);
			}
		}

		out.println(min+" "+cnt);
	}

	public void swap(int[] a,int i,int j){
		int tmp=a[i];
		a[i]=a[j];
		a[j]=tmp;
	}

}

class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Task {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA s = new TaskA();
		s.solve(in, out);
		out.close();
	}
}

class TaskA {
	public void solve(InputReader in, PrintWriter out) {
		int n=in.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();

		int min=Integer.MAX_VALUE;
		int cnt=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[j]>a[i])
					continue;
				swap(a,i,j);
				int tmp=0;
				for(int t=n-1;t>=0;t--){
					for(int k=t-1;k>=0;k--){
						if(a[t]<a[k]){
							tmp++;
						}
					}
				}
				if(tmp==min){
					cnt++;
				}else if(tmp<min){
					min=tmp;
					cnt=1;
				}
				swap(a,i,j);
			}
		}

		out.println(min+" "+cnt);
	}

	public void swap(int[] a,int i,int j){
		int tmp=a[i];
		a[i]=a[j];
		a[j]=tmp;
	}

}

class InputReader {
	private BufferedReader reader;
	private StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

}


/**
 * Created by ckboss on 14-9-4.
 */
import java.util.*;

public class InsertionSort {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int[] a = new int[n+10];
        int[][] dp = new int[n+10][n+10];

        for(int i=1;i<=n;i++)
        {
            a[i]=in.nextInt();
        }

        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<n;j++)
            {
                int t=0;
                if(a[i]<j) t=1;
                dp[i][j]=dp[i-1][j] + t ;
            }

        }

        int ISN=0;
        for(int i=1;i<=n;i++)
            ISN+=i-1-dp[i][a[i]];

        int MinISN=(1<<30);
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++) {
                if (a[i] > a[j]) {
                    int len = j - i - 1;
                    int p = dp[j - 1][a[i]] - dp[i][a[i]];
                    int q = dp[j - 1][a[j]] - dp[i][a[j]];
                    int temp=ISN+2*(q-p)-1;

                    if(temp<MinISN)
                        MinISN=temp;
                }
            }
        }

        int ans=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++) {
                if (a[i] > a[j]) {
                    int len = j - i - 1;
                    int p = dp[j - 1][a[i]] - dp[i][a[i]];
                    int q = dp[j - 1][a[j]] - dp[i][a[j]];
                    int temp=ISN+2*(q-p)-1;

                    if(temp==MinISN)
                       ans++;
                }
            }
        }

        System.out.println(MinISN+" "+ans);
    }
}


import java.util.*;
import java.io.*;

public class InsertionSort {
	static Scanner input = new Scanner(System.in);
	public static void main(String[] args) {
		int n = input.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++)
			arr[i] = input.nextInt();

		int[][] swaps = new int[n][n];
		for(int i=0;i<n;i++) {
			int count = 0;
			for(int j=i-1;j>=0;j--) {
				if(arr[i]>arr[j])
					count++;
				else
					count--;
				swaps[i][j] = count;
			}

			count = 0;
			for(int j=i+1;j<n;j++) {
				swaps[i][j] = count;
				if(arr[i]<arr[j])
					count++;
				else
					count--;
			}
		}

		int minSwaps = 0, minCount = 0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				int change = swaps[i][j] + swaps[j][i];
				if (change < minSwaps) {
					minSwaps = change;
					minCount = 0;
				}
				if (change == minSwaps)
					minCount++;
			}
		}
		for(int i=0;i<n;i++)
			for(int j=i+1;j<n;j++)
				if(arr[j]<arr[i])
					minSwaps++;
		System.out.println(minSwaps+" " +minCount);
	}
}


import java.io.*;
import java.util.*;

public class C implements Runnable {

	int n;
	int[][] cnt;

	private void solve() throws IOException {
		n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		int inv = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < i; j++)
				if (a[j] > a[i])
					inv++;
		cnt = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++)
				if (i > 0) cnt[i][j] = cnt[i - 1][j];
			cnt[i][a[i]]++;
		}
		for (int i = 0; i < n; i++)
			for (int j = n - 2; j >= 0; j--)
				cnt[i][j] += cnt[i][j + 1];
		int best = Integer.MAX_VALUE, cnt = 0;
		for (int i = 0; i < n - 1; i++)
			for (int j = i + 1; j < n; j++) {
				int x = a[i], y = a[j], d = 0;
				d -= res(i - 1, x + 1);
				d += res(j - 1, x + 1);
				if (y > x) d++;
				d -= res(j - 1, y + 1);
				d += res(i - 1, y + 1);
				d -= res(j - 1, 0) - res(j - 1, x);
				d += res(i - 1, 0) - res(i - 1, x);
				d += res(j - 1, 0) - res(j - 1, y);
				d -= res(i - 1, 0) - res(i - 1, y);
				if (d == best) cnt++;
				if (d < best) {
					best = d;
					cnt = 1;
				}
			}
		print(inv + best, cnt);
	}

	int res(int i, int a) {
		if (i < 0 || i >= n || a < 0 || a >= n) return 0;
		return cnt[i][a];
	}

	public static void main(String[] args) {
		new C().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}

	void halt() {
		writer.close();
		System.exit(0);
	}

	void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	void println(Object... objects) {
		print(objects);
		writer.println();
	}

	String nextLine() throws IOException {
		return reader.readLine();
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.util.*;
public class c {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++) data[i] = input.nextInt();
    int[][] dp = new int[n][n];
    for(int i = data[0]; i<n; i++) dp[0][i]++;
    for(int i = 1; i<n; i++)
    {
        for(int j = 0; j<data[i]; j++) dp[i][j] = dp[i-1][j];
        for(int j = data[i]; j<n; j++) dp[i][j] = dp[i-1][j] + 1;
        //System.out.println(i+" "+Arrays.toString(dp[i]));
    }
    int best = -1, count = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
        {
            int min = Math.min(data[i], data[j]);
            int max = Math.max(data[i], data[j]);
            int ans = 2*(dp[j-1][max-1] - dp[i][max-1] - (dp[j-1][min] - dp[i][min]));
            if(data[i] < data[j]) ans = 2*(j-i-1) - ans;
            if(data[i] > data[j]) ans++;
            else ans--;
            //System.out.println(i+" "+j+" "+min+" "+max+" "+ans);
            if(ans > best)
            {
                best = ans;
                count = 1;
            }
            else if(ans == best) count++;
        }
    int x = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
            if(data[i] > data[j])
                x++;
    best = x-best;
    System.out.println(best+" "+count);
}
}


import java.util.*;
public class c {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++) data[i] = input.nextInt();
    int[][] dp = new int[n][n];
    for(int i = data[0]; i<n; i++) dp[0][i]++;
    for(int i = 1; i<n; i++)
    {
        for(int j = 0; j<data[i]; j++) dp[i][j] = dp[i-1][j];
        for(int j = data[i]; j<n; j++) dp[i][j] = dp[i-1][j] + 1;
        //System.out.println(i+" "+Arrays.toString(dp[i]));
    }
    int best = -1, count = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
        {
            int min = Math.min(data[i], data[j]);
            int max = Math.max(data[i], data[j]);
            int ans = 2*(dp[j-1][max-1] - dp[i][max-1] - (dp[j-1][min] - dp[i][min]));
            if(data[i] < data[j]) ans = (j-i-1) - ans;
            if(data[i] > data[j]) ans++;
            else ans--;
            //System.out.println(i+" "+j+" "+min+" "+max+" "+ans);
            if(ans > best)
            {
                best = ans;
                count = 1;
            }
            else if(ans == best) count++;
        }
    int x = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
            if(data[i] > data[j])
                x++;
    best = x-best;
    System.out.println(best+" "+count);
}
}


import java.util.*;
public class c {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++) data[i] = input.nextInt();
    int[][] dp = new int[n][n];
    for(int i = data[0]; i<n; i++) dp[0][i]++;
    for(int i = 1; i<n; i++)
    {
        for(int j = 0; j<data[i]; j++) dp[i][j] = dp[i-1][j];
        for(int j = data[i]; j<n; j++) dp[i][j] = dp[i-1][j] + 1;
        //System.out.println(i+" "+Arrays.toString(dp[i]));
    }
    int best = -1, count = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
        {
            int min = Math.min(data[i], data[j]);
            int max = Math.max(data[i], data[j]);
            int ans = 2*(dp[j-1][max-1] - dp[i][max-1] - (dp[j-1][min] - dp[i][min]));
            if(data[i] < data[j]) ans = -ans;
            if(data[i] > data[j]) ans++;
            else ans--;
            //System.out.println(i+" "+j+" "+min+" "+max+" "+ans);
            if(ans > best)
            {
                best = ans;
                count = 1;
            }
            else if(ans == best) count++;
        }
    int x = 0;
    for(int i = 0; i<n; i++)
        for(int j = i+1; j<n; j++)
            if(data[i] > data[j])
                x++;
    best = x-best;
    System.out.println(best+" "+count);
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class SwapSort {
	public static void main(String[] args) throws IOException {
		BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(rd.readLine());
		n = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(rd.readLine());
		a = new int[n];
		for(int i=0; i<n; i++)
			a[i] = Integer.parseInt(st.nextToken());
		int inv = 0;
		for(int i=0; i<n; i++)
			for(int j=i+1; j<n; j++)
				if(a[i]>a[j])
					inv++;
		dp = new int[5001][5001];
		for(int i=0; i<n; i++){
			dp[i][0] = (a[0]<i ? 1 : 0);
			for(int j=1; j<n; j++){
				dp[i][j] = dp[i][j-1];
				if(a[j]<i) dp[i][j]++;
			}
		}
		d = new int[n][n];
		for(int i=0; i<n; i++){
			d[i][0] = (a[0]>i ? 1 : 0);
			for(int j=1; j<n; j++){
				d[i][j] = d[i][j-1];
				if(a[j]>i) d[i][j]++;
			}
		}
		int pairs = 0;
		int best = n*n;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				int I = inv - countLessThan(a[i], i+1, j-1) + countLessThan(a[j], i+1, j-1) + countMoreThan(a[i], i+1, j-1) -
						countMoreThan(a[j], i+1, j-1);
				if(a[i]>a[j]) I--;
				else I++;
				best = Math.min(best, I);
			}
		}
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				int I = inv - countLessThan(a[i], i+1, j-1) + countLessThan(a[j], i+1, j-1) + countMoreThan(a[i], i+1, j-1) -
						countMoreThan(a[j], i+1, j-1);
				if(a[i]>a[j]) I--;
				else I++;
				if(I==best)
					pairs++;
			}
		}
		System.out.println(best+" "+pairs);
	}

	static int countMoreThan(int num, int from, int to){
		if(from>to) return 0;
		return d[num][to] - (from==0 ? 0 : d[num][from-1]);
	}

	static int countLessThan(int num, int from, int to){
		if(from>to) return 0;
		return dp[num][to] - (from==0 ? 0 : dp[num][from-1]);
	}

	static int[][] dp;
	static int[][] d;

	static int n;
	static int[] a;

}


import java.util.*;
import static java.lang.Math.*;
public class C {
	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextInt();
		}
		//  DP[i][j] is how many of first i elements are <= j
		int[][] DP = new int[N+1][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				DP[i+1][j] = DP[i][j];
				if (a[i] <= j) {
					++DP[i+1][j];
				}
			}
		}

		int best = -1;
		int best_count = 0;
		for (int x = 0; x < N; ++x) {
			for (int y = x+1; y < N; ++y) {
				if (a[x] < a[y])
					continue; // already in order
				// how many elements in a[x+1]...a[y-1] are in a[y]...[x]?
				int B = DP[y][a[x]] - DP[x+1][a[x]];
				int A = DP[y][a[y]] - DP[x+1][a[y]];
				int C = B - A;
				if (C > best) {
					best = C;
					best_count = 0;
				}
				if (C == best)
					++best_count;
			}
		}

		// count inversions
		int num_inv = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = i+1; j < N; ++j) {
				if (a[i] > a[j])
					++num_inv;
			}
		}
		p("%d %d\n", num_inv - 2 * best - 1, best_count);
	}
	void p(String f,Object...p) {
		System.out.printf(f, p);
	}
	public C() {}
	public static void main(String[] args) {
		new C().run();
	}
}


import java.io.*;
import java.util.*;

public class C {

    public static void main(String[] args) throws IOException {
        C solver = new C();
        solver.solve();
    }

    private void solve() throws IOException {
        FastScanner sc = new FastScanner(System.in);
//        sc = new FastScanner("5\n" +
//                "4 0 3 1 2\n");
//        sc = new FastScanner("5\n" +
//                "1 2 3 4 0\n");

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int inv0 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) ++inv0;
            }
        }

        int[][] u = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) u[i][j] = u[i][j - 1] + 1;
                else u[i][j] = u[i][j - 1] - 1;
            }
        }

        int[][] d = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i - 1; j >= 0; j--) {
                if (a[i] > a[j]) d[i][j] = d[i][j + 1] - 1;
                else d[i][j] = d[i][j + 1] + 1;
            }
        }

        int max = Integer.MIN_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int p = u[i][j] - d[j - 1][i];

                if (p > max) {
                    max = p;
                    count = 0;
                }
                if (p == max) {
                    ++count;
                }
            }
        }

        System.out.printf("%d %d\n", inv0 - max, count);
    }

    private static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(File file) throws IOException {
            br = new BufferedReader(new FileReader(file));
        }

        public FastScanner(String s) {
            br = new BufferedReader(new StringReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return "";
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

}


import java.io.*;
import java.util.*;

public class C {

    public static void main(String[] args) throws IOException {
        C solver = new C();
        solver.solve();
    }

    private void solve() throws IOException {
        FastScanner sc = new FastScanner(System.in);
        sc = new FastScanner("5\n" +
                "4 0 3 1 2\n");
        sc = new FastScanner("5\n" +
                "1 2 3 4 0\n");

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int inv0 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) ++inv0;
            }
        }

        int max = Integer.MIN_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int d = 0;
                for (int k = i + 1; k <= j; k++) {
                    if (a[i] > a[k]) ++d;
                    else --d;
                }
                for (int k = i + 1; k < j; k++) {
                    if (a[j] > a[k]) --d;
                    else ++d;
                }
                if (d > max) {
                    max = d;
                    count = 0;
                }
                if (d == max) {
                    ++count;
                }
//                System.out.printf("%d %d %d\n", i, j, d);
            }
        }
        System.out.printf("%d %d\n", inv0 - max, count);
    }

    private static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(File file) throws IOException {
            br = new BufferedReader(new FileReader(file));
        }

        public FastScanner(String s) {
            br = new BufferedReader(new StringReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return "";
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

}


import java.io.*;
import java.util.*;

public class C {

    public static void main(String[] args) throws IOException {
        C solver = new C();
        solver.solve();
    }

    private void solve() throws IOException {
        FastScanner sc = new FastScanner(System.in);
//        sc = new FastScanner("5\n" +
//                "4 0 3 1 2\n");
//        sc = new FastScanner("5\n" +
//                "1 2 3 4 0\n");

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int inv0 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) ++inv0;
            }
        }

        int[][] u = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) u[i][j] = u[i][j - 1] + 1;
                else u[i][j] = u[i][j - 1] - 1;
            }
        }

        int[][] d = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = i - 1; j >= 0; j--) {
                if (a[i] > a[j]) d[i][j] = d[i][j + 1] - 1;
                else d[i][j] = d[i][j + 1] + 1;
            }
        }

        int max = Integer.MIN_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int p = u[i][j] + d[j][i+1];

                if (p > max) {
                    max = p;
                    count = 0;
                }
                if (p == max) {
                    ++count;
                }
            }
        }
        System.out.printf("%d %d\n", inv0 - max, count);
    }

    private static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(File file) throws IOException {
            br = new BufferedReader(new FileReader(file));
        }

        public FastScanner(String s) {
            br = new BufferedReader(new StringReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return "";
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

}


import java.io.*;
import java.util.*;

public class C {

    public static void main(String[] args) throws IOException {
        C solver = new C();
        solver.solve();
    }

    private void solve() throws IOException {
        FastScanner sc = new FastScanner(System.in);
//        sc = new FastScanner("5\n" +
//                "4 0 3 1 2\n");
//        sc = new FastScanner("5\n" +
//                "1 2 3 4 0\n");

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int inv0 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a[i] > a[j]) ++inv0;
            }
        }

        int max = Integer.MIN_VALUE;
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int d = 0;
                for (int k = i + 1; k <= j; k++) {
                    if (a[i] > a[k]) ++d;
                    else --d;
                }
                for (int k = i + 1; k < j; k++) {
                    if (a[j] > a[k]) --d;
                    else ++d;
                }
                if (d > max) {
                    max = d;
                    count = 0;
                }
                if (d == max) {
                    ++count;
                }
//                System.out.printf("%d %d %d\n", i, j, d);
            }
        }
        System.out.printf("%d %d\n", inv0 - max, count);
    }

    private static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public FastScanner(File file) throws IOException {
            br = new BufferedReader(new FileReader(file));
        }

        public FastScanner(String s) {
            br = new BufferedReader(new StringReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    return "";
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define N 5001
#define M 10011
#define INF 1<<30
#define exp (1e-8)
#define mm(a,b) memset((a),b,sizeof(a))
#define PI 3.1415962

int d[N][N],s=0;

int main()
{
    int n,a[N];
    mm(d,0);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i-1;j>=0;j--)
        {
            if(a[j]>a[i])d[i][j]=d[i][j+1]+1;
            else d[i][j]=d[i][j+1];
        }
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[i])d[i][j]=d[i][j-1]+1;
            else d[i][j]=d[i][j-1];
        }
        s+=d[i][0];
    }
    int cnt,mini=INF,ans=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ans=s+2*(d[i][j]-d[j][i]);
            if(ans<mini)
            {
                mini=ans;
                cnt=1;
            }
            else if(ans==mini)
                cnt++;
        }
    }
    printf("%d %d\n",mini,cnt);
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn = 5001;
int n;
int a[maxn];
int b[maxn][maxn];
int tot = 0,ans = 1<<30;
int cnt = 0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    memset(b,0,sizeof(b));
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            b[i][j] = b[i][j-1]+(a[j]<a[i]);
        }
        for(int j=i-1;j>=0;j--){
            b[i][j] = b[i][j+1]+(a[j]<a[i]);
        }
        tot += b[i][n-1];
    }
   /*   cout<<tot<<endl;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<b[i][j]<<" ";
        }
        cout<<endl;
    }*/
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++) if( a[i] > a[j] ){
          int temp = tot - 2*( b[i][j-1] - b[j][i+1] )-1;
          if(temp < ans){ans = temp; cnt = 0;}
          if(temp == ans){cnt++;}
        }
    }

    cout<<ans<<" "<<cnt<<endl;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define N 5001
#define M 10011
#define INF 1<<30
#define exp (1e-8)
#define mm(a,b) memset((a),b,sizeof(a))
#define PI 3.1415962

int d[N][N],s=0;

int main()
{
    int n,a[N];
    mm(d,0);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i-1;j>=0;j--)
        {
            if(a[j]>a[i])d[i][j]=d[i][j+1]+1;
            else d[i][j]=d[i][j+1];
        }
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[i])d[i][j]=d[i][j-1]+1;
            else d[i][j]=d[i][j-1];
        }
        s+=d[i][0];
    }
   // cout<<s<<endl;
  //  cout<<d[1][3]<<endl;
  //  cout<<d[3][1]<<endl;
  //  cout<<s + 2*(d[1][3] - d[3][1]) + (a[1]>a[3])<<endl;
    int cnt,mini=INF,ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans = s + 2*(d[i][j] - d[j][i]) + (a[i]>a[j]);
            if(ans<mini)
            {
                mini=ans;
                cnt=1;
            }
            else if(ans==mini)
                cnt++;
        }
    }
    printf("%d %d\n",mini,cnt);
    return 0;
}/*
5
4 0 3 1 2
4
4 3 2 1
1 2 3 4 0
4 1 2 3
*/


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define N 5001
#define M 10011
#define INF 1<<30
#define exp (1e-8)
#define mm(a,b) memset((a),b,sizeof(a))
#define PI 3.1415962

int d[N][N],s=0;

int main()
{
    int n,a[N];
    mm(d,0);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i-1;j>=0;j--)
        {
            if(a[j]>a[i])d[i][j]=d[i][j+1]+1;
            else d[i][j]=d[i][j+1];
        }
        for(int j=i+1;j<n;j++)
        {
            if(a[j]>a[i])d[i][j]=d[i][j-1]+1;
            else d[i][j]=d[i][j-1];
        }
        s+=d[i][0];
    }
    int cnt,mini=INF,ans=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ans=s+2(d[i][j]-d[j][i]);
            if(ans<mini)
            {
                mini=ans;
                cnt=1;
            }
            else if(ans==mini)
                cnt++;
        }
    }
    printf("%d %d\n",mini,cnt);
    return 0;
}


#include <bits/stdc++.h>

typedef long long LL;
typedef double DB;

#define sf scanf
#define pf printf
#define mp make_pair
#define nl printf("\n")

#define FOR(i,a,b) for(i = a; i <= b; ++i)
#define FORD(i,a,b) for(i = a; i >= b; --i)
#define FORS(i,n) for(i = 0; i < n; ++i)
#define FORM(i,n) for(i = n - 1; i >= 0; --i)
#define reset(i,n) memset(i, n, sizeof(i))
#define open freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define close fclose(stdin); fclose(stdout)

using namespace std;

const LL mod = 1e9 + 7;
const LL INF = 4e18;
const int inf = 2e9;

int gcd(int a, int b) { return b? gcd(b, a%b): a; }
int lcm(int a, int b) { return a/ gcd(a, b)*b; }

int bit[5005], n;
int bef[5005][5005], aft[5005][5005], a[5005], cnt[5005*5005];

void add(int pos) {
    for(; pos <= n; pos |= pos + 1)
        bit[pos]++;
}

int find(int pos) {
    int ret = 0;
    for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
        ret += bit[pos];
    return ret;
}

int main(void)
{
    int i, j;
    sf("%d", &n);
    FORS(i, n) {
        sf("%d", &a[i]);
        FORS(j, n) {
            bef[i][j] = find(n - j);
            //pf("pso : %d num : %d, bef : %d\n", i, j, bef[i][j]);
        }
        add(n - a[i]);
    }
    reset(bit, 0);
    FORM(i, n) {
        FORS(j, n) {
            aft[i][j] = find(j - 1);
            //pf("pso : %d num : %d, aft : %d\n", i, j, aft[i][j]);
        }
        add(a[i]);
    }
    int need = 0;
    FORS(i, n) need += bef[i][a[i]];
    int ans = -1;
    FORS(i, n) FOR(j, i+1, n-1) {
        int geder = bef[j][a[j]] - bef[i][a[j]];
        int gedel = bef[j][a[i]] - bef[i][a[i]];
        int kecilr = aft[i][a[j]] - aft[j][a[j]];
        int kecill = aft[i][a[i]] - aft[j][a[i]];
        int dif = geder - kecilr + kecill - gedel;
        ans = max(ans, dif);
        //pf("%d %d %d\n", i, j, dif);
        if(dif >= 0) cnt[dif]++;
    }
    //cout << ans << endl;
    pf("%d %d\n", need - ans, cnt[ans]);
    return 0;
}


#include <bits/stdc++.h>

typedef long long LL;
typedef double DB;

#define sf scanf
#define pf printf
#define mp make_pair
#define nl printf("\n")

#define FOR(i,a,b) for(i = a; i <= b; ++i)
#define FORD(i,a,b) for(i = a; i >= b; --i)
#define FORS(i,n) for(i = 0; i < n; ++i)
#define FORM(i,n) for(i = n - 1; i >= 0; --i)
#define reset(i,n) memset(i, n, sizeof(i))
#define open freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define close fclose(stdin); fclose(stdout)

using namespace std;

const LL mod = 1e9 + 7;
const LL INF = 4e18;
const int inf = 2e9;

int gcd(int a, int b) { return b? gcd(b, a%b): a; }
int lcm(int a, int b) { return a/ gcd(a, b)*b; }

int bit[5005], n;
int bef[5005][5005], aft[5005][5005], a[5005];

void add(int pos) {
    for(; pos <= n; pos |= pos + 1)
        bit[pos]++;
}

int find(int pos) {
    int ret = 0;
    for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
        ret += bit[pos];
    return ret;
}

int main(void)
{
    int i, j;
    sf("%d", &n);
    FORS(i, n) {
        sf("%d", &a[i]);
        FORS(j, n) {
            bef[i][j] = find(n - j);
        }
        add(n - a[i]);
    }
    reset(bit, 0);
    FORM(i, n) {
        FORS(j, n) {
            aft[i][j] = find(j - 1);
        }
        add(a[i]);
    }
    int need = 0;
    FORS(i, n) need += bef[i][a[i]];
    int ans = -1, cnt = -1;
    FORS(i, n) FOR(j, i+1, n-1) {
        int geder = bef[j][a[j]] - bef[i][a[j]];
        int gedel = bef[j][a[i]] - bef[i][a[i]];
        int kecilr = aft[i][a[j]] - aft[j][a[j]];
        int kecill = aft[i][a[i]] - aft[j][a[i]];
        int dif = geder - kecilr + kecill - gedel;
        if(dif > ans) {
            ans = dif;
            cnt = 1;
        } else if(dif == ans)
            cnt++;
    }
    pf("%d %d\n", need - ans, cnt);
    return 0;
}


#include <bits/stdc++.h>

typedef long long LL;
typedef double DB;

#define sf scanf
#define pf printf
#define mp make_pair
#define nl printf("\n")

#define FOR(i,a,b) for(i = a; i <= b; ++i)
#define FORD(i,a,b) for(i = a; i >= b; --i)
#define FORS(i,n) for(i = 0; i < n; ++i)
#define FORM(i,n) for(i = n - 1; i >= 0; --i)
#define reset(i,n) memset(i, n, sizeof(i))
#define open freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define close fclose(stdin); fclose(stdout)

using namespace std;

const LL mod = 1e9 + 7;
const LL INF = 4e18;
const int inf = 2e9;

int gcd(int a, int b) { return b? gcd(b, a%b): a; }
int lcm(int a, int b) { return a/ gcd(a, b)*b; }

int bit[5005], n;
int bef[5005][5005], aft[5005][5005], a[5005];
map<int,int> cnt;

void add(int pos) {
    for(; pos <= n; pos |= pos + 1)
        bit[pos]++;
}

int find(int pos) {
    int ret = 0;
    for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
        ret += bit[pos];
    return ret;
}

int main(void)
{
    int i, j;
    sf("%d", &n);
    FORS(i, n) {
        sf("%d", &a[i]);
        FORS(j, n) {
            bef[i][j] = find(n - j);
            //pf("pso : %d num : %d, bef : %d\n", i, j, bef[i][j]);
        }
        add(n - a[i]);
    }
    reset(bit, 0);
    FORM(i, n) {
        FORS(j, n) {
            aft[i][j] = find(j - 1);
            //pf("pso : %d num : %d, aft : %d\n", i, j, aft[i][j]);
        }
        add(a[i]);
    }
    int need = 0;
    FORS(i, n) need += bef[i][a[i]];
    int ans = -1;
    FORS(i, n) FOR(j, i+1, n-1) {
        int geder = bef[j][a[j]] - bef[i][a[j]];
        int gedel = bef[j][a[i]] - bef[i][a[i]];
        int kecilr = aft[i][a[j]] - aft[j][a[j]];
        int kecill = aft[i][a[i]] - aft[j][a[i]];
        int dif = geder - kecilr + kecill - gedel;
        ans = max(ans, dif);
        //pf("%d %d %d\n", i, j, dif);
        if(dif >= 0) cnt[dif]++;
    }
    //cout << ans << endl;
    pf("%d %d\n", need - ans, cnt[ans]);
    return 0;
}


#include <bits/stdc++.h>

typedef long long LL;
typedef double DB;

#define sf scanf
#define pf printf
#define mp make_pair
#define nl printf("\n")

#define FOR(i,a,b) for(i = a; i <= b; ++i)
#define FORD(i,a,b) for(i = a; i >= b; --i)
#define FORS(i,n) for(i = 0; i < n; ++i)
#define FORM(i,n) for(i = n - 1; i >= 0; --i)
#define reset(i,n) memset(i, n, sizeof(i))
#define open freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define close fclose(stdin); fclose(stdout)

using namespace std;

const LL mod = 1e9 + 7;
const LL INF = 4e18;
const int inf = 2e9;

int gcd(int a, int b) { return b? gcd(b, a%b): a; }
int lcm(int a, int b) { return a/ gcd(a, b)*b; }

int bit[5005], n, bef[5005][5005], a[5005];

void add(int pos) {
    for(; pos <= n; pos |= pos + 1)
        bit[pos]++;
}

int find(int pos) {
    int ret = 0;
    for(; pos >= 0; pos = (pos & (pos + 1)) - 1)
        ret += bit[pos];
    return ret;
}

int main(void)
{
    int i, j;
    sf("%d", &n);
    FORS(i, n) {
        sf("%d", &a[i]);
        FORS(j, n) {
            bef[i][j] = find(n - j);
            //pf("pso : %d num : %d, bef : %d\n", i, j, bef[i][j]);
        }
        add(n - a[i]);
    }
    int ans = -1, x = -1, y = -1;
    FORS(i, n) FOR(j, i+1, n-1) {
        int pas = bef[i][a[i]] + bef[j][a[j]];
        int now = bef[i][a[j]] + bef[j][a[i]];
        if(pas - now > ans) {
            ans = pas - now;
            x = i, y = j;
        }
    }
    pf("%d %d\n", x, y);
    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

const int INF=1000000000;

template <class T> T sqr(T a) {
    return a*a;
}

const int MAXN=111111;

int n,i,j,iter;
int a[5555],b[5555];
int c[5555][5555];

int getMyC(int r, int x) {
    if (r<0 || x<0) return 0;
    return c[r][x];
}

int getMyC(int r, int x, int y) {
    return getMyC(r,y)-getMyC(r,x-1);
}

int getMyC(int l, int r, int x, int y) {
    return getMyC(r,x,y)-getMyC(l-1,x,y);
}

int trySwap(int i, int j) {
    int oldQ=getMyC(0,j-1,a[j],n-1)+getMyC(j+1,n-1,0,a[j]-1)+getMyC(i+1,n-1,0,a[i]-1)+getMyC(0,i-1,a[i]+1,n-1);
    int nowQ=getMyC(0,j-1,a[i],n-1)+getMyC(j+1,n-1,0,a[i]-1)+getMyC(i+1,n-1,0,a[j]-1)+getMyC(0,i-1,a[j]+1,n-1);
    int res=nowQ-oldQ;
    if (a[i]<a[j]) res++;
    return res;
}

int mini;

int main()
{
    cin >> n;
    for (i=0;i<n;i++) {
        cin >> a[i];
        b[i]=a[i];
    }
    for (i=0;i<n;i++)
        for (j=i;j>0;j--)
            if (b[j]<b[j-1]) {
                iter++;
                swap(b[j],b[j-1]);
            }
    for (i=0;i<n;i++)
        for (j=a[i];j<n;j++)
            c[i][j]++;
    for (i=1;i<n;i++)
        for (j=0;j<n;j++)
            c[i][j]+=c[i-1][j];
    mini=INF;
    for (i=0;i<n;i++)
        for (j=i;j<n;j++) {
            int q=trySwap(i,j);
            if (q+iter<mini) {
                mini=q+iter;
            }
        }
    int x=0;
    for (i=0;i<n;i++)
        for (j=i;j<n;j++)
            if (trySwap(i,j)+iter==mini) x++;
    cout << mini << ' ' << x;
    return 0;
}


#include <iostream>

using namespace std;

const int INF=1000000000;

int n,a[5555];
int c[5555][5555];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i=1;i<=n;i++)
        cin >> a[i];
    for (int i=1;i<=n;i++) {
        a[i]++;c[i][a[i]]++;
    }
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            c[i][j]=c[i-1][j]+c[i][j-1]-c[i-1][j-1]+c[i][j];
    int rev=0;
    for (int i=1;i<=n;i++)
        rev+=c[i-1][n]-c[i-1][a[i]];
    int bestAns=INF,cnt=0;
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++) {
            //if (a[j]>a[i]) continue;
            int cur=rev-2*(c[i][a[j]]+c[j][a[i]]-c[i][a[i]]-c[j][a[j]])-1;
            if (cur<bestAns) bestAns=cur,cnt=0;
            if (cur==bestAns) cnt++;
        }
    cout << bestAns << ' ' << cnt;
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const int maxn = 5000 + 5;
const int INF = 1<<30;

int a[maxn], sum[maxn][maxn], sum2[maxn][maxn];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n; i++)
        scanf("%d", &a[i]);
    for(int i = 0;i < n; i++) {
        sum[i][i] = 0;
        for(int j = i+1;j < n; j++) {
            sum[i][j] = sum[i][j-1];
            if(a[j] < a[i])
                sum[i][j]++;
        }
        sum2[i][i] = 0;
        for(int j = i-1;j >= 0; j--) {
            sum2[i][j] = sum2[i][j+1];
            if(a[i] > a[j])
                sum2[i][j]++;
        }
    }
    int tot = 0;
    for(int i = 0;i < n; i++) {
        for(int j = i+1;j < n; j++) if(a[i] > a[j])
            tot++;
    }
    int mn = INF, ans = 0;
    for(int i = 0;i < n; i++) {
        for(int j = i+1;j < n; j++) {
            int cur = tot + (j-i) - 2*sum[i][j-1] + 2*sum2[j][i+1] - (j-i);
            if(a[i] > a[j]) cur--;
            else    cur++;
            if(cur < mn) {
                mn = cur; ans = 1;
            }
            else if(cur == mn)  ans++;
        }
    }
    printf("%d %d\n", mn, ans);
    return 0;
}


/*
 * Author:  DreamHigh
 * Created Time:  2013/11/15 19:15:11
 * File Name: A.cpp
 * solve: A.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<set>
#include<iostream>
#include<vector>
#include<queue>
//ios_base::sync_with_stdio(false);
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;
#define sz(v) ((int)(v).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define clr(x) memset(x,0,sizeof(x))
#define clrs( x , y ) memset(x,y,sizeof(x))
#define out(x) printf(#x" %d\n", x)
#define sqr(x) ((x) * (x))
typedef long long LL;

const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 5100;
int num[maxn];
int cha[maxn];
int temp[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin>>n)
    {
        rep(i,0,n)
        {
            scanf("%d",&num[i]);
            cha[i] = i - num[i];
            temp[i] = cha[i];
        }

        sort(cha,cha+n);

        if(cha[0] == cha[n-1])
        {
            cout<<0<<" "<<0<<endl;
            continue;
        }
        int a = 0;
        int b = 0;
        rep(i,0,n)
            if(cha[i] == cha[0])
                a++;

        rep(i,0,n)
            if(cha[i] == cha[n-1])
                b++;

        int ans2 = a*b;

        int A,B;
        rep(i,0,n)
        {
            if(temp[i] == cha[0])
                A = i;
            if(temp[i] == cha[n-1])
                B = i;
        }

        swap(num[A],num[B]);

        rep(i,0,n)
            cha[i] = i - num[i];

        int ans1 = 0;
        rep(i,0,n)
            if(cha[i] > 0)
                ans1 += cha[i];

        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}


/*
 * Author:  DreamHigh
 * Created Time:  2013/11/15 19:15:11
 * File Name: A.cpp
 * solve: A.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<set>
#include<iostream>
#include<vector>
#include<queue>
//ios_base::sync_with_stdio(false);
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;
#define sz(v) ((int)(v).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define clr(x) memset(x,0,sizeof(x))
#define clrs( x , y ) memset(x,y,sizeof(x))
#define out(x) printf(#x" %d\n", x)
#define sqr(x) ((x) * (x))
typedef long long LL;

const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 5100;
int num[maxn];
int cha[maxn];
int temp[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin>>n)
    {
        rep(i,0,n)
        {
            scanf("%d",&num[i]);
            cha[i] = i - num[i];
            temp[i] = cha[i];
        }

        sort(cha,cha+n);

        int a = 0;
        int b = 0;
        rep(i,0,n)
            if(cha[i] == cha[0])
                a++;

        rep(i,0,n)
            if(cha[i] == cha[n-1])
                b++;

        int ans2 = a*b;

        int A,B;
        rep(i,0,n)
        {
            if(temp[i] == cha[0])
                A = i;
            if(temp[i] == cha[n-1])
                B = i;
        }

        swap(num[A],num[B]);

        rep(i,0,n)
            cha[i] = i - num[i];

        int ans1 = 0;
        rep(i,0,n)
            if(cha[i] > 0)
                ans1 += cha[i];

        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}


/*
 * Author:  DreamHigh
 * Created Time:  2013/11/15 21:09:18
 * File Name: A.cpp
 * solve: A.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<set>
#include<iostream>
#include<vector>
#include<queue>
//ios_base::sync_with_stdio(false);
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;
#define sz(v) ((int)(v).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define clr(x) memset(x,0,sizeof(x))
#define clrs( x , y ) memset(x,y,sizeof(x))
#define out(x) printf(#x" %d\n", x)
#define sqr(x) ((x) * (x))
typedef long long LL;

const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 5002;
int num[maxn];
int sum[maxn][maxn];//sum[i][j] means in range i+1~j there are sum[i][j] numbers are smaller than num[i];
int sum1[maxn][maxn];//sum[i][j] means in range i+1~j there are sum[i][j] numbers are smaller than num[j];
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin>>n)
    {
        repf(i,1,n)
            scanf("%d",&num[i]);

        repf(i,1,n)
        {
            sum[i][i] = 0;
            repf(j,i+1,n)
              {
                  sum[i][j] = sum[i][j-1];
                  if(num[i] > num[j])
                      sum[i][j]++;
              }
        }

        repd(j,n,1)
        {
            sum1[j][j] = 0;
            repd(i,j-1,1)
            {
               sum1[i][j] = sum1[i+1][j];
              if(num[i] < num[j])
                  sum1[i][j]++;
            }
        }
        int cnt = 0;
        repf(i,1,n)
            repf(j,i+1,n)
            {
                if(num[i] > num[j])
                    cnt++;
            }
        //cout<<cnt<<endl;
        int ans1 = cnt;
        int ans2 = 0;
        //swap num[i] and num[j]
        repf(i,1,n)
            repf(j,i+1,n)
            {
               // int temp = cnt - sum[i][j-1] + sum1[i][j-1] + (j - 1 - i - sum[i][j-1]) - (j - 1 - i - sum1[i][j-1]);
                int temp = cnt + (j-i) - 2*sum[i][j-1] + 2*sum1[i+1][j] - (j-i);
                if(num[i] < num[j])
                    temp++;
                else
                    temp--;
                ans1 = min(ans1,temp);
            }
         repf(i,1,n)
            repf(j,i+1,n)
            {
                int temp = cnt + (j-i) - 2*sum[i][j-1] + 2*sum1[i+1][j] - (j-i);
                if(num[i] < num[j])
                    temp++;
                else
                    temp--;
                if(temp == ans1)
                    ans2++;
            }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}


/*
 * Author:  DreamHigh
 * Created Time:  2013/11/15 21:09:18
 * File Name: A.cpp
 * solve: A.cpp
 */
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<set>
#include<iostream>
#include<vector>
#include<queue>
//ios_base::sync_with_stdio(false);
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;
#define sz(v) ((int)(v).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define clr(x) memset(x,0,sizeof(x))
#define clrs( x , y ) memset(x,y,sizeof(x))
#define out(x) printf(#x" %d\n", x)
#define sqr(x) ((x) * (x))
typedef long long LL;

const int INF = 1000000000;
const double eps = 1e-8;
const int maxn = 5002;
int num[maxn];
int sum[maxn][maxn];//sum[i][j] means in range i+1~j there are sum[i][j] numbers are smaller than num[i];
int sum1[maxn][maxn];//sum[i][j] means in range i+1~j there are sum[i][j] numbers are smaller than num[j];
int main()
{
    //freopen("in.txt","r",stdin);
    int n;
    while(cin>>n)
    {
        repf(i,1,n)
            scanf("%d",&num[i]);

        repf(i,1,n)
        {
            sum[i][i] = 0;
            repf(j,i+1,n)
              {
                  sum[i][j] = sum[i][j-1];
                  if(num[i] > num[j])
                      sum[i][j]++;
              }
        }

        repd(j,n,1)
        {
            sum1[j][j] = 0;
            repd(i,j-1,1)
            {
               sum1[i][j] = sum1[i+1][j];
              if(num[i] < num[j])
                  sum1[i][j]++;
            }
        }
        int cnt = 0;
        repf(i,1,n)
            repf(j,i+1,n)
            {
                if(num[i] > num[j])
                    cnt++;
            }
        //cout<<cnt<<endl;
        int ans1 = cnt;
        int ans2 = 0;
        //swap num[i] and num[j]
        repf(i,1,n)
            repf(j,i+1,n)
            {
                int temp = cnt - sum[i][j-1] + sum1[i+1][j] + (j - 1 - i - sum[i][j-1]) - (j - 1 - i - sum1[i+1][j]);
                //int temp = cnt + (j-i) - 2*sum[i][j-1] + 2*sum1[i+1][j] - (j-i);
                if(num[i] < num[j])
                    temp++;
                else
                    temp--;
                ans1 = min(ans1,temp);
            }
         repf(i,1,n)
            repf(j,i+1,n)
            {
                int temp = cnt + (j-i) - 2*sum[i][j-1] + 2*sum1[i+1][j] - (j-i);
                if(num[i] < num[j])
                    temp++;
                else
                    temp--;
                if(temp == ans1)
                    ans2++;
            }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}


#include<stdio.h>
int ab(int x)
{
    if(x<0)
    return -x;
    else
    return x;
    }
int main()
{
    int n,sum=0,k,cou,min=1000000000,i,a[5001],j,summ;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&k);
        a[k]=i;
        }
    for(i=0;i<n;i++)
    sum+=ab(a[i]-i);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            summ=sum;
            summ=summ-ab(a[i]-i)-ab(a[j]-j)+ab(a[i]-j)+ab(a[j]-i);
            if(summ<min)
            {
                cou=1;
                min=summ;
                }
            else if(summ==min)
            cou++;
            }
        }
    printf("%d %d",min/2,cou);
    scanf(" ");
    }


#include<stdio.h>
int ab(int x)
{
    if(x<0)
    return -x;
    else
    return x;
    }
int main()
{
    int n,sum=0,k,cou,min=1000000000,i,a[5001],j,summ;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&k);
        a[k]=i;
        }
    for(i=0;i<n;i++)
    sum+=ab(a[i]-i);
    for(i=0;i<n;i++)
    {
        for(j=i;j<n;j++)
        {
            summ=sum;
            summ=summ-ab(a[i]-i)-ab(a[j]-j)+ab(a[i]-j)+ab(a[j]-i);
            if(summ<min)
            {
                cou=1;
                min=summ;
                }
            else if(summ==min)
            cou++;
            }
        }
    printf("%d %d",min/2,cou);
    scanf(" ");
    }


# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <functional> // greater<int>()
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <list>
# include <map>
# include <set>
# include <cstdio>
# include <cstdlib>
# include <cmath>
# include <ctime>
# include <cstring>
# include <cctype>
# include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

/* MACROS */

# define  all(A)        (A).begin() , (A).end()
# define  rall(A)        (A).rbegin() , (A).rend()
# define  sz(A)            (int)(A).size()
# define  pb            push_back
# define  ppb            pop_back
# define  mp            make_pair
# define  bir            first
# define  iki            second
# define  rsz(A,X)        (A).resize(X)
# define  ln(A)            (int)(A).length()
# define  FILL(X, A)    memset((X), (A), sizeof(X))
# define  minof(X)        min_element(all(X))-X.begin()
# define  maxof(X)        max_element(all(X))-X.begin()
# define  square(X)        ((X)*(X))
# define  cube(X)        ((X)*(X)*(X))

# define  FOR(i, a, b)    for (int i=a; i<b; i++)
# define  FORD(i, a, b)    for (int i=a-1; i>=b; i--)
# define  REP(i,n)        for( int i=0 ; i<n ; i++ )
# define  REPD(i,n)        for( int i=n-1 ; i>=0 ; i-- )
# define  TR(it,container)  \
        for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
# define  setmap_found(container, element) (container.find(element) != container.end())
# define  vector_found(container, element) (find(all(container),element) != container.end())
# define  DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;

//time_t st=clock();

using namespace std;

/* TYPE DEFINITIONS */
typedef        long long        i64;
typedef        vector<int>        vi;
typedef        vector<vi>        vvi;
typedef        pair<int,int>    pi;
typedef        vector<pi>        vpi;
typedef        vector<vpi>        vvpi;
typedef        vector<i64>        v64;
typedef        vector<v64>        vv64;
typedef        pair<i64,i64>    p64;
typedef        vector<p64>     vp64;
typedef        vector<vp64>    vvp64;
typedef        vector<string>    vs;
typedef        vector<vs>        vvs;
typedef        vector<bool>    vb;
typedef        vector<vb>        vvb;
typedef        vector<char>    vc;
typedef        vector<vc>        vvc;

/* TOOLS */
template <class T> inline T max(T a, T b, T c){   return max(a, max(b, c));   }
template <class T> inline T min(T a, T b, T c){   return min(a, min(b, c));   }
template <class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' '; cerr<<endl;}

/* ALGEBRA */
template <class T> T gcd (T a, T b){    return ( b==(T)0 ?a :gcd(b,a%b) );    }
template <class T> T lcm (T a , T b){    return a/gcd(a,b)*b;    }
template <class T> T mathround (T x){    i64 i64x=(i64)x; if( x<i64x+0.5 ) return (T)i64x; return (T)i64x+1;    }
template <class T> bool isprime(T x)
{
    int till = (T)sqrt(x+.0);
    if (x <= 1) return 0;
    if (x == 2) return 1;
    if (x%2 == 0) return 0;
    for (int i=3; i<=till; i+=2) if (x%i == 0) return 0;
    return 1;
}

/* CONSTANTS */
//const double Pi = 4.0 * atan(1.0); // 4*atan(1)
//int dir[8][2] = {{+1,+0},{-1,+0},{+0,+1},{+0,-1},{-1,-1},{+1,+1},{+1,-1},{-1,+1}};
//int mon[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

/* {END} */

int n;
int arr[5001];
int big[5001][5001];

int bigger(int x, int l, int r) {
    return big[x][r] - big[x][l-1];
}
int smaller(int x, int l, int r) {
    return (r-l+1)-bigger(x,l,r);
}

int main()
{
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> arr[i];

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            big[i][j] = big[i][j-1] + (arr[i] < arr[j]);

    int work = 0;
    for (int i = 1; i <= n; i++)
        work += big[i][i];

//    printf("work is %d\n", work);

    int minc = 1;
    int minv = 5000*5000;
    for (int i = 1; i <= n; i++)
        for (int j = i+1; j <= n; j++) {
            int v;

            if (j-i == 1)
                v = (arr[i] > arr[j] ?-1 :+1);
            else
                v =  + bigger(i,i+1,j) - smaller(i,i+1,j) - bigger(j,i+1,j-1) + smaller(j,i+1,j-1);

//            printf("ifswap %d %d increase %d\n", i, j, v);
//            printf("ifswap %d %d swaps %d\n\n", i, j, work+v);

            if (minv > v) {
                minv = v;
                minc = 1;
            } else if (minv == v) {
                minc++;
            }
        }

    cout << work+minv << " " << minc;

//    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);        // needs disabled ios_base::sync_with_stdio(false);
//    freopen("output.txt", "w", stdout);        // needs disabled ios_base::sync_with_stdio(false);
//    cin >> noskipws;
//    cin >> skipws;

//    cout<<clock()-st;
    /*
    getchar();
    getchar();
    */
    return EXIT_SUCCESS;
}