#include <cstdio>

template <int n> struct T
{
  enum { value = n };
};

template <int l, int r, template <int> class Type> struct For
{
  enum { value = Type<l>::value + For<l + 1, r, Type>::value  };
};

template <int l, template <int> class Type> struct For<l, l, Type>
{
  enum { value = 0 };
};

int main()
{
  int x = For<5, 1000, T>::value;
  printf("%d\n", x);
  return 0;
}