How to add HTML class to main menu list? Theme Developer shows me that I need to use theme_links()

I can use this function, but I want to alter markup for main menu only.

I've tried funtion names: mytheme_links__menu_main_menu or mytheme_links__system_main_menu

but it seems that these function aren't invoked.
One way to achieve this to create a theme key in your template file like this:

function THEMENAME_theme(){
    $items = array();

    $items['custom_main_menu'] = array(
      'variables' =&gt; array('links' =&gt; array()),
  );

  return $items;
}


And then use the function below 

function THEMENAME_custom_main_menu($menu){
  $menu['links'][367]['#below'][526]['#attributes']['id'] = "news_ma_international";
  // this will add id to link # 367
}


Now to print the main menu in your page.tpl.php use something like this

 &lt;?php $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu')); ?&gt;
                &lt;?php print theme('custom_main_menu', array(
                  'links' =&gt; $main_menu_tree,
                  'attributes' =&gt; array(
                    'id' =&gt; 'main-menu-links',
                    'class' =&gt; array('links', 'clearfix'),
                  ),
                  'heading' =&gt; array(
                    'text' =&gt; t('Main menu'),
                    'level' =&gt; 'h2',
                    'class' =&gt; array('element-invisible'),
                  ),
                )); ?&gt;


I hope this will help!