package lab3;

import java.util.Scanner;

public class Example6 {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        System.out.print("Enter array size: ");

        if (!in.hasNextInt()) {
            System.out.println("Incorrect value. Size must be an integer.");
            in.close();
            return;
        }

        int size = in.nextInt();

        if (size <= 0) {
            System.out.println("Incorrect value. Size must be positive.");
            in.close();
            return;
        }

        int[] array = new int[size];

        int value = 2;
        for (int i = 0; i < size; i++) {
            array[i] = value;
            value += 5;
        }

        System.out.println("Array elements:");
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }

        in.close();
    }
}
