static int bsHelper(List<Integer>A, int t, boolean lower) {
		int l=0, r=A.size()-1;
		while (l<=r) {
			int m=l+(r-l)/2;
			int a=A.get(m);
			if (a==t) {
				if (lower) {
					if (m==l||A.get(m-1)!=a)
						return m;
					else 
						r=m-1;
				} else {
					if (m==r||A.get(m+1)!=a)
						return m;
					else 
						l=m+1;
				}
			} else if (a<t) {
				l=m+1;
			} else 
				r=m-1;
		}
		return -1;
	}