#include <iostream>
using namespace std;


struct Node {
    int data;           
    Node* next;        

    
    Node(int value) {
        data = value;
        next = nullptr;
    }
};


Node* createLinkedListFromArray(int arr[], int size) {
    if (size == 0) return nullptr; // If array is empty, return nullptr

    // Create the head node
    Node* head = new Node(arr[0]);
    Node* current = head;

    
    for (int i = 1; i < size; i++) {
        current->next = new Node(arr[i]);
        current = current->next;
    }

    return head;
}


void printLinkedList(Node* head) {
    Node* current = head;
    while (current != nullptr) {
        cout << current->data << " -> ";
        current = current->next;
    }
    cout << "nullptr" << endl;
}

int main() {
    int arr[] = {10, 20, 30, 40, 50};
    int size = sizeof(arr) / sizeof(arr[0]);

    
    Node* head = createLinkedListFromArray(arr, size);

   
    printLinkedList(head);

    return 0;
}
