#include <cstdio>                                                               

template<int n> struct Table
{
  enum { len = n };
  static int values[n];
  static int get( int i );
  static int calc;
};

template<int *a, int n> struct Do
{
  static int value;
};

template<int *a> struct Do<a, -1>
{
  static int value;
};

template<int *a, int n> int Do<a, n>::value = (a[n] = n * n) + Do<a, n - 1>::value;
template<int *a> int Do<a, -1>::value = -1;

template<int n> int Table<n>::values[n];
template<int n> int Table<n>::get( int i ) { return values[i]; }
template<int n> int Table<n>::calc = Do<Table<n>::values, n - 1>::value;

#define MAX 20

int main()
{
  int x = Table<MAX>::calc;

  printf("x = %d\n", x);
  for (int i = 0; i < MAX; i++)
    printf("%d : %d\n", i, Table<MAX>::get(i));
  return 0;
}