function r = foc_uc(n1,param);

l     = length(n1);
km1   = param(:,1);
ku1   = param(:,2);
k2    = param(:,3);
z     = param(:,4);
tauc  = param(:,5);
taun  = param(:,6);
g     = param(:,7);
thetm1= param(:,8);
thetu1= param(:,9);
thet2 = param(:,10);
x     = param(:,11);
a1    = param(1,12);
a2    = param(1,13);
rho   = param(1,14);
psi   = param(1,15);
scale = param(1,16);

n2    = ( a2/a1* (1-thet2)./(1-thetm1-thetu1).*((k2./z).^(thet2*rho)./ ...
          ( (km1./z).^(thetm1*rho).*(ku1./z).^(thetu1*rho) )).* ...
           n1.^(1-rho*(1-thetm1-thetu1)) ).^ ...
          (ones(l,1)./(1-rho*(1-thet2)));

y1    = km1.^thetm1.*ku1.^thetu1.*(z.*n1).^(1-thetm1-thetu1);
y2    = k2.^thet2.*(z.*n2).^(1-thet2);
y     = scale*(a1*y1.^rho+a2*y2.^rho).^(1/rho);
c     = y-x-g;
p2    = scale^rho*a2*(y./y2).^(1-rho);

r     = (1-n1-n2).*(1-taun).*p2.*(1-thet2).*(k2./n2).^ ...
             thet2/psi.* z.^(1-thet2)./(1+tauc)-c;

