Suppose we have the following network topology:

To avoid the burden of setting multiple Static Routes for each device, we can use route summarization to lessen the administrative burden of setting each route up. This also has the benefit of lowering memory usage on the routers, since the Routing Table will be smaller. It is possible to accomplish this when our networks are contiguous. For example, we can use:
R1#
ip route 10.1.0.0 255.255.0.0 10.0.0.2
This will allow R1 to use 10.0.0.2 as the next-hop address for all packets going to the 10.1.x.x networks (because of the subnet mask).
Note that this summarization does not have to be made on IP Address Class boundaries. For example, lets say we want to summarize the 10.1.0.0 to 10.1.3.0 range (rather than the entire 10.1.0.0 range). We can do so with:
R1#
ip route 10.1.0.0 255.255.252.0 10.0.0.2
This works because all the networks start with 10.1. Thus we can begin our subnet mask with 255.255. However, we only want the range of networks from 10.1.0 to 10.1.3. Since this is 4 networks, we can use as mask of 252 (11111100 in binary) - this gives us 2 bits at the end, which translates to 4 possible values.
Longest Prefix Match
Whenever a router is assessing its routing table, it will always use the route with the longest prefix (that is, the longest subnet mask) if the routes are overlapping.
Note
Another way to think about longest prefix match it to see that the route with most specificity will be selected first
Suppose that we added a 5th router, R5, to the topology above in the following manner:

If we don’t modify our Routing Table, connections to the 10.1.3.0/24 network would route via R2, R3, R4. However, we can modify the routing table as follows:
ip route 10.1.0.0 255.255.0.0 10.0.0.2
ip route 10.1.3.0 255.255.255.0 10.0.3.2
This gives access to the 10.1.3.0/24 network directly via R5. Additionally, this means that we have two distinct routes to get to the network: one via the chain of routes, and one directly via R5. The logic in the router software will match the routing request on both table entries; however, the entry for 10.1.3.0 has a longer prefix of 255.255.255.0, and thus will be selected first.