foo.cc: In function 'int main()':
foo.cc:8:16: warning: non-constant array new length must be specified without parentheses around the type-id [-Wvla]
a = new(int[n]);
^
foo.cc:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
foo.cc:9:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (int i = 0; i < n; i++) { scanf("%d", a + i); x += a[i]; }
~~~~~^~~~~~~~~~~~~