#include int n; int *x, *y, *p; int h, nh; int hladaj(int h) { int s = 0, t, i; t = h; for (i = 0; i < n; i++) p[i] = 0; do { i = 0; while (i < n) { if ((p[i] == 0) && (y[i] == y[t]) && (x[i] > x[t])) { s += x[i] - x[t]; p[i] = 1; t = i; i = 0; } else i++; } i = 0; while (i < n) { if ((p[i] == 0) && (x[i] == x[t]) && (y[i] < y[t])) { s += y[t] - y[i]; p[i] = 1; t = i; i = 0; } else i++; } i = 0; while (i < n) { if ((p[i] == 0) && (y[i] == y[t]) && (x[i] < x[t])) { s += x[t] - x[i]; p[i] = 1; t = i; i = 0; } else i++; } i = 0; while (i < n) { if ((p[i] == 0) && (x[i] == x[t]) && (y[i] > y[t])) { s += y[i] - y[t]; p[i] = 1; t = i; i = 0; } else i++; } } while (t != h); return s; } int main() { int i, c; scanf("%d", &n); while (n) { x = new int[n]; y = new int[n]; p = new int[n]; h = 0; for (i = 0; i < n; i++) { scanf("%d%d", x + i, y + i); p[i] = 0; if ((y[i] > y[h]) || ((y[i] == y[h]) && (x[i] < x[h]))) h = i; } p[h] = 1; c = hladaj(h); printf("The length of the fence will be %d units.\n", c); delete x; delete y; delete p; scanf("%d", &n); } return 0; }