The material array doesn't reflect the number of materials you're using.
It reflects the number of times the renderer has to switch between materials to render the next thing.
So if, for example, you're rendering 5 images (a, b, c, d, e) from 2 different textures.
And a, b, c comes from material1, and d and e comes from material2.
If you have to render the parts in this order : a, e, b, c, d.
Then you'll have an array: material1(a), material2(e), material1(bc), material2(d).
And if you render in this order : d, e, a, b, c.
You'll have an array: material2(de), material1(abc).
If you open the dragon example scene, you'll see the same thing.
So as much as possible, you have to either group things coming from the same texture as much as you can, or make the images you need fit in one texture.