Establishing a foundation in music theory can help immensely with writing music. It will increase the ease in which you hear and arrange notes so you can play and compose music faster.
The videos below are meant to help introduce you to key concepts and exercises to get you started. A lot of it is math in many ways and it may need a few views just to familiarize yourself with the ideas. If you wish to pursue this topic further, formal instruction and lessons are recommended.