3
-1 1 -1
 4
45 -1 41 -1
 1
-1
 5
40 -1 44 46 48
 6
43 40 37 34 -1 -1
 7
-1 2 4 -1 4 1 5
 19
23 26 -1 -1 35 38 41 -1 -1 -1 53 -1 59 62 6 7 8 9 -1
 6
-1 2 6 -1 -1 6
 16
3 8 13 18 23 -1 -1 -1 43 48 53 45 -1 -1 -1 -1
 13
25 24 23 22 24 27 -1 33 -1 2 2 2 -1
 12
-1 17 -1 54 -1 64 -1 74 79 84 -1 94
 8
-1 12 14 16 18 20 -1 -1
 13
2 -1 3 1 3 1 -1 1 3 -1 -1 1 1
 5
-1 40 42 -1 46
 2
1000000000 -1
 14
-1 5 3 -1 -1 31 31 31 -1 31 -1 -1 4 7
 3
-1 1000000000 999999999
 7
32 33 34 -1 -1 37 38
 1
1000000000
 10
29 27 -1 23 42 -1 -1 45 -1 -1
 3
39 42 -1
 15
-1 28 -1 32 34 26 -1 26 -1 -1 26 26 26 -1 -1
 3
1000000000 999999999 1000000000
 17
-1 -1 -1 -1 64 68 72 -1 45 46 47 48 49 50 51 52 53
 3
-1 1 1000000000
 2
-1 1000000000
 3
999999999 -1 1000000000
 1
1
 2
1000000000 1000000000
 3
999999999 1000000000 -1
 7
11 8 5 -1 -1 -1 -1
 3
-1 1 2
 2
-1 21
 8
-1 -1 1 7 -1 9 5 2
 11
9 21 17 13 -1 -1 -1 -1 -1 -1 -1
 3
-1 1000000000 -1
 6
-1 6 1 -1 -1 -1
 1
65
 20
-1 32 37 -1 -1 -1 57 -1 -1 40 31 33 -1 -1 39 47 43 -1 35 32
 5
-1 1 7 -1 5
 18
21 19 -1 -1 -1 48 50 -1 54 -1 5 1 -1 -1 -1 37 36 35
 9
42 39 36 33 -1 -1 -1 34 39
 2
-1 -1

1
 1
 1
 1
 1
 3
 2
 2
 2
 3
 2
 1
 6
 1
 1
 3
 1
 1
 1
 2
 1
 2
 2
 2
 2
 1
 2
 1
 1
 1
 2
 2
 1
 3
 3
 1
 2
 1
 5
 2
 4
 2
 1

//package round241;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.List;

public class D {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
//	String INPUT = "7 -1 -1 2 -1 5 -1 -1";
//	String INPUT = "9\r\n" + 
//			"-1 6 -1 2 -1 4 7 -1 2";
	
	void solve()
	{
		int n = ni();
		long[] a = new long[n];
		int m1 = 0;
		for(int i = 0;i < n;i++){
			a[i] = ni();
			if(a[i] == -1)m1++;
		}
		if(m1 == n || m1 == n-1){
			out.println(1);
			return;
		}
		
		int[] ft = new int[n+1];
		for(int i = 0;i < n;i++){
			if(a[i] > -1)addFenwick(ft, i, 1);
		}
		
		long[][] can = new long[n][3];
		for(int i = 0;i < n;i++){
			Arrays.fill(can[i], -1);
		}
		for(int i = 0;i < n;i++){
			if(a[i] == -1){
				int br = before(ft, i);
				int bl = br != -1 ? before(ft, br) : -1;
				int al = after(ft, i);
				int ar = al != -1 ? after(ft, al) : -1;
				if(br != -1 && bl != -1 && (a[br]-a[bl]) % (br-bl) == 0 && a[br] + (a[br]-a[bl])*(i-br)/(br-bl) >= 1){
					long q = a[br] + (a[br]-a[bl])*(i-br)/(br-bl);
					can[i][0] = q;
				}
				
				if(br != -1 && al != -1 && (a[al]-a[br]) % (al-br) == 0 && a[br] + (a[al]-a[br])*(i-br)/(al-br) >= 1){
					long q = a[br] + (a[al]-a[br])*(i-br)/(al-br);
					can[i][1] = q;
				}
				
				if(al != -1 &&ar != -1 && (a[ar]-a[al]) % (ar-al) == 0 && a[al]-(a[ar]-a[al])*(al-i) / (ar-al) >= 1){
					long q = a[al]-(a[ar]-a[al])*(al-i) / (ar-al);
					can[i][2] = q;
				}
			}
		}
//		tr(can);
//		tr(a);
		
		List<Frontier> dp = new ArrayList<Frontier>();
		dp.add(new Frontier(-1L, Integer.MIN_VALUE, 0));
		for(int i = 0;i < n;i++){
			List<Frontier> ndp = new ArrayList<Frontier>();
			long[] go = null;
			if(a[i] >= 0){
				go = new long[]{a[i]};
			}else if(can[i][0] + can[i][1] + can[i][2] == -3){
				int aft = after(ft, i);
				int bef = before(ft, i);
				go = new long[2];
				int p = 0;
				if(aft != -1)go[p++] = a[aft];
				if(bef != -1)go[p++] = a[bef];
				go = Arrays.copyOf(go, p);
			}else{
				go = new long[3];
				int p = 0;
				for(int j = 0;j < 3;j++){
					if(can[i][j] != -1){
						go[p++] = can[i][j];
					}
				}
				go = Arrays.copyOf(go, p);
			}

//			tr(go);
			for(Frontier f : dp){
				for(long g : go){
					if(f.a != -1){
						if(f.d != Integer.MIN_VALUE){
							if(f.a + f.d == g){
								ndp.add(new Frontier(f.a+f.d, f.d, f.num));
							}else{
								ndp.add(new Frontier(g, Integer.MIN_VALUE, f.num+1));
							}
						}else{
							ndp.add(new Frontier(g, (int)(g - f.a), f.num));
						}
					}else{
						ndp.add(new Frontier(g, Integer.MIN_VALUE, f.num+1));
					}
				}
			}
//			tr(ndp);
			Collections.sort(ndp, new Comparator<Frontier>() {
				public int compare(Frontier a, Frontier b) {
					if(a.a != b.a)return Long.compare(a.a, b.a);
					if(a.d != b.d)return Long.compare(a.d, b.d);
					return a.num - b.num;
				}
			});
			for(int j = ndp.size()-1;j >= 1;j--){
				Frontier f = ndp.get(j), r = ndp.get(j-1);
				if(f.a == r.a && f.d == r.d){
					ndp.remove(j);
				}
			}
			
//			tr(ndp.size());
			dp = ndp;
		}
		
		int min = Integer.MAX_VALUE;
		for(Frontier f : dp){
			min = Math.min(min, f.num);
		}
		out.println(min);
	}
	
	static class Frontier
	{
		long a; // -1 any
		int d; // MIN_VALUE undefined
		int num;
		public Frontier(long a, int d, int num) {
			this.a = a;
			this.d = d;
			this.num = num;
		}
		@Override
		public String toString() {
			return "Frontier [a=" + a + ", d=" + d + ", num=" + num + "]";
		}
	}
	
	public static int sumFenwick(int[] ft, int i)
	{
		int sum = 0;
		for(i++;i > 0;i -= i&-i)sum += ft[i];
		return sum;
	}
	
	public static void addFenwick(int[] ft, int i, int v)
	{
		if(v == 0 || i < 0)return;
		int n = ft.length;
		for(i++;i < n;i += i&-i)ft[i] += v;
	}
	
	public static int findGFenwick(int[] ft, int v)
	{
		int i = 0;
		int n = ft.length;
		for(int b = Integer.highestOneBit(n);b != 0 && i < n;b >>= 1){
			if(i + b < n){
				int t = i + b;
				if(v >= ft[t]){
					i = t;
					v -= ft[t];
				}
			}
		}
		return v != 0 ? -(i+1) : i-1;
	}
	
	public static int valFenwick(int[] ft, int i)
	{
		return sumFenwick(ft, i) - sumFenwick(ft, i-1);
	}
	
	public static int[] restoreFenwick(int[] ft)
	{
		int n = ft.length-1;
		int[] ret = new int[n];
		for(int i = 0;i < n;i++)ret[i] = sumFenwick(ft, i);
		for(int i = n-1;i >= 1;i--)ret[i] -= ret[i-1];
		return ret;
	}
	
	public static int before(int[] ft, int x)
	{
		int u = sumFenwick(ft, x-1);
		if(u == 0)return -1;
		return findGFenwick(ft, u-1)+1;
	}
	
	public static int after(int[] ft, int x)
	{
		int u = sumFenwick(ft, x);
		int f = findGFenwick(ft, u);
		if(f+1 >= ft.length-1)return -1;
		return f+1;
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new D().run(); }
	
	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}
