diff --git a/output/pdf/space-exploration-4.pdf b/output/pdf/space-exploration-4.pdf
new file mode 100644
index 0000000..e0be116
Binary files /dev/null and b/output/pdf/space-exploration-4.pdf differ
diff --git a/tasks/space-exploration/docs/space-exploration-4.md b/tasks/space-exploration/docs/space-exploration-4.md
new file mode 100644
index 0000000..405880a
--- /dev/null
+++ b/tasks/space-exploration/docs/space-exploration-4.md
@@ -0,0 +1,54 @@
+# Space Exploration 4
+
+**Title:** Исследуй Планету
+**Subtitle:** Собери ресурсы, решая примеры!
+**Footer bubble:** Итого собрано ресурсов:
+
+## Layout
+
+- 2 columns, 20 problems per page
+- Icons: pack1 (pages 1–6), pack2 (pages 7–9)
+
+## Problem Pattern
+
+A ± B, where:
+- B is from 1 to 10
+- Result is from 1 to 29
+- Each problem crosses a 10-boundary: either 10 or 20 (strictly, not just touching)
+
+Types:
+- Add crossing 10: A ∈ [1,9], B such that A+B ∈ [11,29]
+- Add crossing 20: A ∈ [11,19], B such that A+B ∈ [21,29]
+- Sub crossing 10: A ∈ [11,19], B such that A−B ∈ [1,9]
+- Sub crossing 20: A ∈ [21,29], B such that A−B ∈ [11,19]
+
+All 4 types are mixed randomly on every page.
+
+## Pages
+
+### Page 1 (pack1)
+- **Hero:** spaceship1.jpeg, direction: row-reverse
+
+### Page 2 (pack1)
+- **Hero:** spaceship2.jpeg, direction: row
+
+### Page 3 (pack1)
+- **Hero:** spaceship3.png, direction: row-reverse
+
+### Page 4 (pack1)
+- **Hero:** spaceship4.jpeg, direction: row
+
+### Page 5 (pack1)
+- **Hero:** spaceship5.jpeg, direction: row-reverse
+
+### Page 6 (pack1)
+- **Hero:** spaceship6.jpeg, direction: row
+
+### Page 7 (pack2)
+- **Hero:** spaceship7.jpeg, direction: row-reverse
+
+### Page 8 (pack2)
+- **Hero:** spaceship8.jpeg, direction: row
+
+### Page 9 (pack2)
+- **Hero:** spaceship9.jpeg, direction: row-reverse
diff --git a/tasks/space-exploration/docs/space-exploration-4.template.html b/tasks/space-exploration/docs/space-exploration-4.template.html
new file mode 100644
index 0000000..c67a212
--- /dev/null
+++ b/tasks/space-exploration/docs/space-exploration-4.template.html
@@ -0,0 +1,1917 @@
+
+
+
+
+
+
+
+
+
+ Исследуй Планету
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 3 + 9 =
+
+
+
+
+
+
+

+
+ 22 − 10 =
+
+
+
+
+
+
+

+
+ 3 + 8 =
+
+
+
+
+
+
+

+
+ 9 + 2 =
+
+
+
+
+
+
+

+
+ 21 − 5 =
+
+
+
+
+
+
+

+
+ 8 + 8 =
+
+
+
+
+
+
+

+
+ 6 + 10 =
+
+
+
+
+
+
+

+
+ 15 + 7 =
+
+
+
+
+
+
+

+
+ 29 − 10 =
+
+
+
+
+
+
+

+
+ 15 − 8 =
+
+
+
+
+
+
+

+
+ 24 − 8 =
+
+
+
+
+
+
+

+
+ 24 − 10 =
+
+
+
+
+
+
+

+
+ 19 + 3 =
+
+
+
+
+
+
+

+
+ 17 − 9 =
+
+
+
+
+
+
+

+
+ 1 + 10 =
+
+
+
+
+
+
+

+
+ 14 − 9 =
+
+
+
+
+
+
+

+
+ 4 + 8 =
+
+
+
+
+
+
+

+
+ 19 − 10 =
+
+
+
+
+
+
+

+
+ 13 − 6 =
+
+
+
+
+
+
+

+
+ 28 − 10 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 27 − 9 =
+
+
+
+
+
+
+

+
+ 23 − 10 =
+
+
+
+
+
+
+

+
+ 9 + 5 =
+
+
+
+
+
+
+

+
+ 26 − 10 =
+
+
+
+
+
+
+

+
+ 13 − 10 =
+
+
+
+
+
+
+

+
+ 9 + 9 =
+
+
+
+
+
+
+

+
+ 24 − 9 =
+
+
+
+
+
+
+

+
+ 16 + 9 =
+
+
+
+
+
+
+

+
+ 8 + 5 =
+
+
+
+
+
+
+

+
+ 15 − 6 =
+
+
+
+
+
+
+

+
+ 14 + 9 =
+
+
+
+
+
+
+

+
+ 16 − 9 =
+
+
+
+
+
+
+

+
+ 12 + 10 =
+
+
+
+
+
+
+

+
+ 11 − 10 =
+
+
+
+
+
+
+

+
+ 4 + 9 =
+
+
+
+
+
+
+

+
+ 11 − 9 =
+
+
+
+
+
+
+

+
+ 23 − 9 =
+
+
+
+
+
+
+

+
+ 18 − 10 =
+
+
+
+
+
+
+

+
+ 13 − 7 =
+
+
+
+
+
+
+

+
+ 19 + 3 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 13 − 5 =
+
+
+
+
+
+
+

+
+ 5 + 6 =
+
+
+
+
+
+
+

+
+ 16 − 10 =
+
+
+
+
+
+
+

+
+ 18 − 9 =
+
+
+
+
+
+
+

+
+ 19 − 10 =
+
+
+
+
+
+
+

+
+ 23 − 5 =
+
+
+
+
+
+
+

+
+ 15 + 7 =
+
+
+
+
+
+
+

+
+ 18 − 10 =
+
+
+
+
+
+
+

+
+ 1 + 10 =
+
+
+
+
+
+
+

+
+ 26 − 10 =
+
+
+
+
+
+
+

+
+ 18 + 8 =
+
+
+
+
+
+
+

+
+ 9 + 4 =
+
+
+
+
+
+
+

+
+ 15 − 10 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 12 + 9 =
+
+
+
+
+
+
+

+
+ 14 + 9 =
+
+
+
+
+
+
+

+
+ 12 − 8 =
+
+
+
+
+
+
+

+
+ 29 − 10 =
+
+
+
+
+
+
+

+
+ 27 − 8 =
+
+
+
+
+
+
+

+
+ 13 + 10 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 14 + 8 =
+
+
+
+
+
+
+

+
+ 14 − 5 =
+
+
+
+
+
+
+

+
+ 1 + 10 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 5 + 8 =
+
+
+
+
+
+
+

+
+ 11 + 10 =
+
+
+
+
+
+
+

+
+ 2 + 9 =
+
+
+
+
+
+
+

+
+ 22 − 4 =
+
+
+
+
+
+
+

+
+ 8 + 4 =
+
+
+
+
+
+
+

+
+ 17 + 7 =
+
+
+
+
+
+
+

+
+ 28 − 10 =
+
+
+
+
+
+
+

+
+ 24 − 6 =
+
+
+
+
+
+
+

+
+ 12 + 10 =
+
+
+
+
+
+
+

+
+ 22 − 8 =
+
+
+
+
+
+
+

+
+ 7 + 7 =
+
+
+
+
+
+
+

+
+ 19 + 2 =
+
+
+
+
+
+
+

+
+ 11 − 5 =
+
+
+
+
+
+
+

+
+ 16 − 10 =
+
+
+
+
+
+
+

+
+ 4 + 10 =
+
+
+
+
+
+
+

+
+ 6 + 10 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 13 − 6 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 11 + 10 =
+
+
+
+
+
+
+

+
+ 14 + 10 =
+
+
+
+
+
+
+

+
+ 3 + 8 =
+
+
+
+
+
+
+

+
+ 12 − 6 =
+
+
+
+
+
+
+

+
+ 9 + 7 =
+
+
+
+
+
+
+

+
+ 5 + 9 =
+
+
+
+
+
+
+

+
+ 27 − 9 =
+
+
+
+
+
+
+

+
+ 12 − 3 =
+
+
+
+
+
+
+

+
+ 13 + 9 =
+
+
+
+
+
+
+

+
+ 14 + 7 =
+
+
+
+
+
+
+

+
+ 16 + 10 =
+
+
+
+
+
+
+

+
+ 17 + 4 =
+
+
+
+
+
+
+

+
+ 17 − 9 =
+
+
+
+
+
+
+

+
+ 15 − 6 =
+
+
+
+
+
+
+

+
+ 4 + 8 =
+
+
+
+
+
+
+

+
+ 13 − 7 =
+
+
+
+
+
+
+

+
+ 21 − 2 =
+
+
+
+
+
+
+

+
+ 17 + 5 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 12 − 9 =
+
+
+
+
+
+
+

+
+ 7 + 5 =
+
+
+
+
+
+
+

+
+ 14 − 6 =
+
+
+
+
+
+
+

+
+ 15 − 6 =
+
+
+
+
+
+
+

+
+ 29 − 10 =
+
+
+
+
+
+
+

+
+ 19 + 3 =
+
+
+
+
+
+
+

+
+ 15 − 7 =
+
+
+
+
+
+
+

+
+ 16 − 10 =
+
+
+
+
+
+
+

+
+ 14 − 9 =
+
+
+
+
+
+
+

+
+ 14 − 7 =
+
+
+
+
+
+
+

+
+ 23 − 5 =
+
+
+
+
+
+
+

+
+ 23 − 9 =
+
+
+
+
+
+
+

+
+ 13 + 8 =
+
+
+
+
+
+
+

+
+ 2 + 9 =
+
+
+
+
+
+
+

+
+ 24 − 7 =
+
+
+
+
+
+
+

+
+ 9 + 10 =
+
+
+
+
+
+
+

+
+ 7 + 6 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 12 + 9 =
+
+
+
+
+
+
+

+
+ 4 + 7 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 14 − 7 =
+
+
+
+
+
+
+

+
+ 29 − 10 =
+
+
+
+
+
+
+

+
+ 15 − 8 =
+
+
+
+
+
+
+

+
+ 18 + 9 =
+
+
+
+
+
+
+

+
+ 28 − 10 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 13 + 10 =
+
+
+
+
+
+
+

+
+ 11 − 10 =
+
+
+
+
+
+
+

+
+ 2 + 9 =
+
+
+
+
+
+
+

+
+ 6 + 6 =
+
+
+
+
+
+
+

+
+ 26 − 8 =
+
+
+
+
+
+
+

+
+ 13 − 8 =
+
+
+
+
+
+
+

+
+ 8 + 10 =
+
+
+
+
+
+
+

+
+ 25 − 10 =
+
+
+
+
+
+
+

+
+ 4 + 10 =
+
+
+
+
+
+
+

+
+ 14 − 8 =
+
+
+
+
+
+
+

+
+ 12 − 3 =
+
+
+
+
+
+
+

+
+ 5 + 6 =
+
+
+
+
+
+
+

+
+ 11 − 7 =
+
+
+
+
+
+
+

+
+ 23 − 4 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 18 − 10 =
+
+
+
+
+
+
+

+
+ 9 + 5 =
+
+
+
+
+
+
+

+
+ 18 + 8 =
+
+
+
+
+
+
+

+
+ 22 − 5 =
+
+
+
+
+
+
+

+
+ 12 − 7 =
+
+
+
+
+
+
+

+
+ 16 − 9 =
+
+
+
+
+
+
+

+
+ 27 − 8 =
+
+
+
+
+
+
+

+
+ 9 + 10 =
+
+
+
+
+
+
+

+
+ 19 + 7 =
+
+
+
+
+
+
+

+
+ 21 − 3 =
+
+
+
+
+
+
+

+
+ 12 − 10 =
+
+
+
+
+
+
+

+
+ 12 + 9 =
+
+
+
+
+
+
+

+
+ 17 + 7 =
+
+
+
+
+
+
+

+
+ 1 + 10 =
+
+
+
+
+
+
+

+
+ 2 + 9 =
+
+
+
+
+
+
+

+
+ 23 − 6 =
+
+
+
+
+
+
+

+
+ 21 − 8 =
+
+
+
+
+
+
+

+
+ 11 + 10 =
+
+
+
+
+
+
+

+
+ 16 − 10 =
+
+
+
+
+
+
+

+
+ 18 + 9 =
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+
+
+

+
+ 16 + 6 =
+
+
+
+
+
+
+

+
+ 14 + 8 =
+
+
+
+
+
+
+

+
+ 29 − 10 =
+
+
+
+
+
+
+

+
+ 17 + 5 =
+
+
+
+
+
+
+

+
+ 28 − 9 =
+
+
+
+
+
+
+

+
+ 25 − 9 =
+
+
+
+
+
+
+

+
+ 15 + 9 =
+
+
+
+
+
+
+

+
+ 18 − 10 =
+
+
+
+
+
+
+

+
+ 17 − 10 =
+
+
+
+
+
+
+

+
+ 17 − 8 =
+
+
+
+
+
+
+

+
+ 12 + 9 =
+
+
+
+
+
+
+

+
+ 24 − 8 =
+
+
+
+
+
+
+

+
+ 7 + 8 =
+
+
+
+
+
+
+

+
+ 13 − 7 =
+
+
+
+
+
+
+

+
+ 4 + 10 =
+
+
+
+
+
+
+

+
+ 24 − 10 =
+
+
+
+
+
+
+

+
+ 15 + 10 =
+
+
+
+
+
+
+

+
+ 11 − 6 =
+
+
+
+
+
+
+

+
+ 4 + 9 =
+
+
+
+
+
+
+

+
+ 13 + 8 =
+
+
+
+
+
+
+
+
+
+
diff --git a/tasks/space-exploration/index.html b/tasks/space-exploration/index.html
index b2ae430..e64eb2c 100644
--- a/tasks/space-exploration/index.html
+++ b/tasks/space-exploration/index.html
@@ -92,6 +92,16 @@
+
+
+
+
Space Exploration 4
+
9 pagespack1 + pack2
Addition & subtraction crossing 10 and 20 • A ± B, B ∈ [1,10], result ∈ [1,29]
+
+
+
diff --git a/tasks/space-exploration/scripts/generate-crossing.mjs b/tasks/space-exploration/scripts/generate-crossing.mjs
new file mode 100644
index 0000000..ba18c06
--- /dev/null
+++ b/tasks/space-exploration/scripts/generate-crossing.mjs
@@ -0,0 +1,211 @@
+/**
+ * Generate space-exploration-4.template.html — 9-page worksheet with
+ * addition and subtraction crossing 10 and 20.
+ *
+ * Usage: node tasks/space-exploration/scripts/generate-crossing.mjs
+ * Output: tasks/space-exploration/docs/space-exploration-4.template.html
+ */
+
+import fs from 'fs';
+import path from 'path';
+import { fileURLToPath } from 'url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const ROOT = path.resolve(__dirname, '../../..');
+
+const pack1Icons = fs.readdirSync(path.join(ROOT, 'assets/themes/nms/icons/pack1'))
+ .filter(f => f.endsWith('.png'))
+ .map(f => `assets/themes/nms/icons/pack1/${f}`);
+
+const pack2Icons = fs.readdirSync(path.join(ROOT, 'assets/themes/nms/icons/pack2'))
+ .filter(f => f.endsWith('.png'))
+ .map(f => `assets/themes/nms/icons/pack2/${f}`);
+
+function shuffle(arr) {
+ const a = [...arr];
+ for (let i = a.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [a[i], a[j]] = [a[j], a[i]];
+ }
+ return a;
+}
+
+function randInt(min, max) {
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+}
+
+function pickAlignment() {
+ const opts = ['justify-start', 'justify-center', 'justify-end'];
+ return opts[Math.floor(Math.random() * opts.length)];
+}
+
+// Generate 20 unique crossing problems (A ± B crosses 10 or 20)
+function genCrossingProblems() {
+ const problems = [];
+ const seen = new Set();
+
+ while (problems.length < 20) {
+ const isAdd = Math.random() < 0.5;
+ const crossAt = Math.random() < 0.5 ? 10 : 20;
+ let a, b;
+
+ if (isAdd) {
+ if (crossAt === 10) {
+ // A ∈ [1,9], A+B ∈ [11,min(29,A+10)]
+ a = randInt(1, 9);
+ const minB = 11 - a;
+ const maxB = Math.min(10, 29 - a);
+ if (minB > maxB) continue;
+ b = randInt(minB, maxB);
+ } else {
+ // A ∈ [11,19], A+B ∈ [21,min(29,A+10)]
+ a = randInt(11, 19);
+ const minB = 21 - a;
+ const maxB = Math.min(10, 29 - a);
+ if (minB > maxB) continue;
+ b = randInt(minB, maxB);
+ }
+ const result = a + b;
+ if (result < 1 || result > 29) continue;
+ const expr = `${a} + ${b}`;
+ if (!seen.has(expr)) { seen.add(expr); problems.push(expr); }
+ } else {
+ if (crossAt === 10) {
+ // A ∈ [11,19], A−B ∈ [1,9]
+ a = randInt(11, 19);
+ const minB = a - 9;
+ const maxB = Math.min(10, a - 1);
+ if (minB > maxB || minB < 1) continue;
+ b = randInt(Math.max(1, minB), maxB);
+ } else {
+ // A ∈ [21,29], A−B ∈ [11,19]
+ a = randInt(21, 29);
+ const minB = a - 19;
+ const maxB = Math.min(10, a - 11);
+ if (minB > maxB || minB < 1) continue;
+ b = randInt(Math.max(1, minB), maxB);
+ }
+ const result = a - b;
+ if (result < 1 || result > 29) continue;
+ const expr = `${a} − ${b}`;
+ if (!seen.has(expr)) { seen.add(expr); problems.push(expr); }
+ }
+ }
+
+ return problems;
+}
+
+const pages = [
+ { hero: 'assets/themes/nms/hero-images/spaceship1.jpeg', footer: 'assets/themes/nms/footers/planet1.jpeg', dir: 'flex-row-reverse', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship2.jpeg', footer: 'assets/themes/nms/footers/planet2.jpeg', dir: '', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship3.png', footer: 'assets/themes/nms/footers/planet3.jpeg', dir: 'flex-row-reverse', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship4.jpeg', footer: 'assets/themes/nms/footers/planet4.jpeg', dir: '', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship5.jpeg', footer: 'assets/themes/nms/footers/planet5.jpeg', dir: 'flex-row-reverse', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship6.jpeg', footer: 'assets/themes/nms/footers/planet6.jpeg', dir: '', pack: 'pack1' },
+ { hero: 'assets/themes/nms/hero-images/spaceship7.jpeg', footer: 'assets/themes/nms/footers/planet7.jpeg', dir: 'flex-row-reverse', pack: 'pack2' },
+ { hero: 'assets/themes/nms/hero-images/spaceship8.jpeg', footer: 'assets/themes/nms/footers/planet8.jpeg', dir: '', pack: 'pack2' },
+ { hero: 'assets/themes/nms/hero-images/spaceship9.jpeg', footer: 'assets/themes/nms/footers/planet9.jpeg', dir: 'flex-row-reverse', pack: 'pack2' },
+];
+
+// Icons: pages 0-5 → pack1 (shuffled twice across 3-page sections), pages 6-8 → pack2
+const iconSections = [
+ shuffle(pack1Icons), // pages 0-2
+ shuffle(pack1Icons), // pages 3-5
+ shuffle(pack2Icons), // pages 6-8
+];
+
+function buildProblemCard(icon, expression, alignment) {
+ return `
+
+

+
+ ${expression} =
+
+
+
`;
+}
+
+function buildPage(pageIdx, isLast) {
+ const pg = pages[pageIdx];
+ const sectionIdx = Math.floor(pageIdx / 3);
+ const posInSection = pageIdx % 3;
+ const sectionIcons = iconSections[sectionIdx];
+ const pageIcons = sectionIcons.slice(posInSection * 20, posInSection * 20 + 20);
+
+ const problems = genCrossingProblems();
+ const dirClass = pg.dir ? ` ${pg.dir}` : '';
+ const breakStyle = isLast ? '' : ' style="break-after: page;"';
+
+ const cards = problems.map((expr, i) =>
+ buildProblemCard(pageIcons[i], expr, pickAlignment())
+ ).join('\n\n');
+
+ return `
+
+
+
+
+

+
+
+
+
+ Итого собрано ресурсов:
+
+
+
+
+
+
+

+
+
+
Собери ресурсы, решая примеры!
+
+
+
+
+
+${cards}
+
+
+
+
`;
+}
+
+const htmlPages = pages.map((_, i) => buildPage(i, i === pages.length - 1)).join('\n\n');
+
+const html = `
+
+
+
+
+
+
+
+
+ Исследуй Планету
+
+
+
+
+
+${htmlPages}
+
+
+
+`;
+
+const outPath = path.join(__dirname, '..', 'docs', 'space-exploration-4.template.html');
+fs.writeFileSync(outPath, html, 'utf-8');
+console.log(`Generated: ${outPath} (${pages.length} pages, ${pages.length * 20} problems)`);
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..cadb8c0
--- /dev/null
+++ b/test.js
@@ -0,0 +1,21 @@
+function cars(A = [0, 1, 0, 1, 1]) {
+ let s = 0;
+ const countedA = A.reverse().map(x => {
+ if (!x) {
+ return 0
+ }
+ s++;
+ return s
+ }).reverse();
+
+ let sum = 0;
+ while(countedA.length) {
+ const car = countedA.shift();
+ if(car) {
+ continue
+ }
+ const count = countedA.find(n => n > 0);
+ sum = sum + count;
+ }
+ return sum
+}
\ No newline at end of file