Since you are arriving in T4, that means you are on a One World Airline (Iberia, BA, American, etc.). It sounds like you already have the international ticket into Madrid and are going to buy a second ticket to Pamplona. The times should work, but it would be much better for you to have this all on one ticket. Then you would not need to pick up and re-check your bag in Madrid, it would be shipped directly from the US to your final destination (Pamplona). It would also mean that if your flight into Madrid was so delayed that you missed your connection, you would not lose your ticket to Pamplona, but would be rebooked by the airlines. If they are separate tickets, and you miss your connection, you will lose that ticket. If it’s all on one ticket, you do not need to leave the airport terminal. You would take the train from the satellite terminal of T4 (international arrivals) to the main T4 terminal, go through the internal security (for transit passengers) and get to your departure gate.
With separate tickets, that means you are going to have to leave the secure part of the airport, go to baggage claim and pick up your bag, and then start the check-in process all over again. That is more complicated and much more time consuming.
Is there any way to add the Madrid-Pamplona leg onto your existing ticket? (Or maybe you haven’t yet bought your ticket, which would be the best situation!).