a few solutions
Accumulate both diagonal sums simultaneously.  Subtract the middle sum once if it was added twice.\n\n---\n\n1-Liner Solutions:\n\nKotlin\n\nclass Solution {\n 
Accumulate both diagonal sums simultaneously.  Subtract the middle sum once if it was added twice.\n\n---\n\n**1-Liner Solutions:**\n\n*Kotlin*\n```\nclass Solution {\n    fun diagonalSum(A: Array<IntArray>): Int {\n        var N = A.size\n        return A.mapIndexed{ i, _ -> A[i][i] + A[i][N - 1 - i] }!!.sum() - (if (N % 2 == 1) A[N / 2][N / 2] else 0)\n    }\n}\n```\n\n*Javascript*\n```\nlet diagonalSum = (A, N = A.length, f = Math.floor) => _.sum(A.map((_, i) => A[i][i] + A[i][N - 1 - i])) - (N & 1 ? A[f(N / 2)][f(N / 2)] : 0);\n```\n\n*Python3*\n```\nclass Solution:\n    def diagonalSum(self, A: List[List[int]]) -> int:\n        N = len(A)\n        return sum([A[i][i] + A[i][N - 1 - i] for i in range(N)]) - (A[N // 2][N // 2] if N & 1 else 0)\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VI = vector<int>;\n    using VVI = vector<VI>;\n    int diagonalSum(VVI& A) {\n        int N = A.size();\n        return accumulate(A.begin(), A.end(), 0, [i = -1, N, &A](auto sum, auto _) mutable {\n            ++i; return sum + A[i][i] + A[i][N - 1 - i];\n        }) - (N & 1 ? A[N / 2][N / 2] : 0);\n    }\n};\n```\n\n---\n\n**Verbose Solutions:**\n\n*Kotlin*\n```\nclass Solution {\n    fun diagonalSum(A: Array<IntArray>): Int {\n        var N = A.size\n        var total = 0\n        for (i in 0 until N)\n            total += A[i][i] + A[i][N - 1 - i]  // \uD83C\uDFAF accumulate sum of both diagonals simultaneously\n        if (A.size % 2 == 1)\n            total -= A[N / 2][N / 2]            // \u2B50\uFE0F subtract middle element once if it was added twice\n        return total\n    }\n}\n```\n    \n*Javascript*\n```\nlet diagonalSum = (A, sum = 0, f = Math.floor) => {\n    let N = A.length;\n    for (let i = 0; i < N; ++i)\n        sum += A[i][i] + A[i][N - 1 - i];  // \uD83C\uDFAF accumulate sum of both diagonals simultaneously\n    if (N & 1)\n        sum -= A[f(N / 2)][f(N / 2)];      // \u2B50\uFE0F subtract middle element once if it was added twice\n    return sum;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def diagonalSum(self, A: List[List[int]], sum = 0) -> int:\n        N = len(A)\n        for i in range(N):\n            sum += A[i][i] + A[i][N - 1 - i]  # \uD83C\uDFAF accumulate sum of both diagonals simultaneously\n        if N & 1:\n            sum -= A[N // 2][N // 2]          # \u2B50\uFE0F subtract middle element once if it was added twice\n        return sum\n```\n    \n*C++*\n```\nclass Solution {\npublic:\n    using VI = vector<int>;\n    using VVI = vector<VI>;\n    int diagonalSum(VVI& A, int sum = 0) {\n        int N = A.size();\n        for (auto i{ 0 }; i < N; ++i)\n            sum += A[i][i] + A[i][N - 1 - i];  // \uD83C\uDFAF accumulate sum of both diagonals simultaneously\n        if (N & 1)\n            sum -= A[N / 2][N / 2];            // \u2B50\uFE0F subtract middle element once if it was added twice\n        return sum;\n    }\n};\n```
[]