Alexander has chosen a natural number $N>1$ and has written down in a line,and in increasing order,all his positive divisors $d_1<d_2<\ldots <d_s$ (where $d_1=1$ and $d_s=N$).For each pair of neighbouring numbers,he has found their greater common divisor.The sum of all these $s-1$ numbers (the greatest common divisors) is equal to $N-2$.Find all possible values of $N$.
1. **Given Information:**
   - Alexander has chosen a natural number \( N > 1 \).
   - He has written down all positive divisors of \( N \) in increasing order: \( d_1 < d_2 < \ldots < d_s \) where \( d_1 = 1 \) and \( d_s = N \).
   - For each pair of neighboring numbers, he has found their greatest common divisor (gcd).
   - The sum of all these \( s-1 \) gcds is equal to \( N-2 \).

2. **Objective:**
   - Find all possible values of \( N \).

3. **Initial Analysis:**
   - We know that \( \gcd(a, b) \leq |a - b| \) for any \( a \) and \( b \).
   - Applying this to the divisors \( d_1, d_2, \ldots, d_s \), we get:
     \[
     \gcd(d_1, d_2) + \gcd(d_3, d_4) + \cdots + \gcd(d_{s-1}, d_s) \leq (d_2 - d_1) + (d_3 - d_2) + \cdots + (d_s - d_{s-1})
     \]
   - Simplifying the right-hand side:
     \[
     (d_2 - d_1) + (d_3 - d_2) + \cdots + (d_s - d_{s-1}) = d_s - d_1 = N - 1
     \]
   - Given that the sum of the gcds is \( N-2 \), we must have:
     \[
     \gcd(d_1, d_2) + \gcd(d_3, d_4) + \cdots + \gcd(d_{s-1}, d_s) = N-2
     \]
   - Therefore, the inequality must be tight except for one pair where it is off by 1:
     \[
     \gcd(d_i, d_{i+1}) = d_{i+1} - d_i - 1
     \]

4. **Detailed Analysis:**
   - For the inequality to be tight, we must have \( \gcd(d_i, d_{i+1}) = d_{i+1} - d_i \) for all pairs except one.
   - For the exceptional pair, \( \gcd(d_i, d_{i+1}) = d_{i+1} - d_i - 1 \).

5. **Considering the Exceptional Pair:**
   - Let \( d_{i+1} - d_i = 2 \). Then \( d_i \) and \( d_{i+1} \) are odd.
   - This implies there are two consecutive factors of \( N \) which can be written as \( 2n-1 \) and \( 2n+1 \).

6. **Checking for Other Factors:**
   - If \( N \neq (2n-1)(2n+1) \), then the factors \( \frac{N}{2n+1} \) and \( \frac{N}{2n-1} \) are also consecutive and different from our original pair.
   - We have:
     \[
     \gcd\left(\frac{N}{2n+1}, \frac{N}{2n-1}\right) = \frac{N}{(2n-1)(2n+1)}
     \]
   - And:
     \[
     \frac{N}{2n-1} - \frac{N}{2n+1} = \frac{2N}{(2n-1)(2n+1)}
     \]
   - This shows that equality does not hold here either.

7. **Conclusion:**
   - Thus, we must have \( N = (2n-1)(2n+1) \), which is odd.
   - If \( 2n-1 \neq 1 \), then \( 1 \) and \( p \) are consecutive and different from \( 2n-1 \) and \( 2n+1 \), where \( p \) is the least prime divisor of \( N \).
   - Since \( \gcd(1, p) = 1 \neq p-1 \), equality does not hold there either.
   - Therefore, we are forced to have \( 2n-1 = 1 \), which yields \( N = 1 \cdot 3 = 3 \).

The final answer is \( \boxed{3} \)