// Arup Guha
// 3/4/2018
// Solution to 2018 February USACO Bronze Problem: Taming the Herd

import java.util.*;
import java.io.*;

public class taming {

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(new File("taming.in"));

		// Read in the array.
		int n = stdin.nextInt();
		int[] vals = new int[n];
		for (int i=0; i<n; i++)
			vals[i] = stdin.nextInt();

		// Used to check for consistency.
		boolean ok = true;

		// Reconstruct known values here.
		int[] reconstruct = new int[n];
		Arrays.fill(reconstruct, -1);
		for (int i=n-1; i>=0; i--) {
			if (vals[i] >= 0) {
				for (int j=i,k=vals[i]; k>=0; j--,k--) {
					if (reconstruct[j] != -1 && reconstruct[j] != k)
						ok = false;
					reconstruct[j] = k;
				}
			}
		}

		// See if anything is inconsistent.

		for (int i=0; i<n; i++) {
			if (i == 0 && vals[i] > 0) ok = false;
			if (vals[i] >= 0 && vals[i] != reconstruct[i])
				ok = false;
		}

		// Change this if they were -1.
		vals[0] = 0;
		reconstruct[0] = 0;

		PrintWriter out = new PrintWriter(new FileWriter("taming.out"));

		// Inconsistent.
		if (!ok)
			out.println(-1);

		// Solve it.
		else {

			// Here is our minimum answer.
			int min = 0;
			for (int i=0; i<n; i++)
				if (reconstruct[i] == 0)
					min++;

			// Any open day is a day for rebellion!
			int max = min;
			for (int i=0; i<n; i++)
				if (reconstruct[i] == -1)
					max++;

			out.println(min+" "+max);
		}

		// Ta da!
		out.close();
		stdin.close();
	}

}