Let's denote a function 

<image>

You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Input

The first line contains one integer n (1 ≤ n ≤ 200000) — the number of elements in a.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of the array. 

Output

Print one integer — the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Examples

Input

5
1 2 3 1 3


Output

4


Input

4
6 6 5 5


Output

0


Input

4
6 6 4 4


Output

-8

Note

In the first example:

  1. d(a1, a2) = 0; 
  2. d(a1, a3) = 2; 
  3. d(a1, a4) = 0; 
  4. d(a1, a5) = 2; 
  5. d(a2, a3) = 0; 
  6. d(a2, a4) = 0; 
  7. d(a2, a5) = 0; 
  8. d(a3, a4) = - 2; 
  9. d(a3, a5) = 0; 
  10. d(a4, a5) = 2. 
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
namespace fastinput {
template <class T = int>
inline T readInt();
inline long double readDouble();
inline int readUInt();
inline int readChar();
inline void readWord(char *s);
inline bool readLine(char *s);
inline bool isEof();
inline int peekChar();
inline bool seekEof();
template <class T>
inline void writeInt(T x, int len = -1);
template <class T>
inline void writeUInt(T x, int len = -1);
inline void writeChar(int x);
inline void writeWord(const char *s);
inline void writeDouble(long double x, int len = 0);
inline void flush();
static const int buf_size = 4096;
static char buf[buf_size];
static int buf_len = 0, buf_pos = 0;
inline bool isEof() {
  if (buf_pos == buf_len) {
    buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
    if (buf_pos == buf_len) return 1;
  }
  return 0;
}
inline int getChar() { return isEof() ? -1 : buf[buf_pos++]; }
inline int peekChar() { return isEof() ? -1 : buf[buf_pos]; }
inline bool seekEof() {
  int c;
  while ((c = peekChar()) != -1 && c <= 32) buf_pos++;
  return c == -1;
}
inline int readChar() {
  int c = getChar();
  while (c != -1 && c <= 32) c = getChar();
  return c;
}
inline int readUInt() {
  int c = readChar(), x = 0;
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return x;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
inline long double readDouble() {
  int s = 1, c = readChar();
  long double x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  if (c == '.') {
    c = getChar();
    long double coef = 1;
    while ('0' <= c && c <= '9') x += (c - '0') * (coef *= 0.1), c = getChar();
  }
  return s == 1 ? x : -x;
}
inline void readWord(char *s) {
  int c = readChar();
  while (c > 32) *s++ = (char)c, c = getChar();
  *s = 0;
}
inline bool readLine(char *s) {
  int c = getChar();
  while (c != '\n' && c != -1) *s++ = (char)c, c = getChar();
  *s = 0;
  return c != -1;
}
static int write_buf_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_buf_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
  write_buf[write_buf_pos++] = (char)x;
}
inline void flush() {
  if (write_buf_pos)
    fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
}
template <class T>
inline void writeInt(T x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n < output_len) s[n++] = '0';
  while (n--) writeChar(s[n]);
}
template <class T>
inline void writeUInt(T x, int output_len) {
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = (char)('0' + (char)(x % 10)), x /= 10;
  while (n < output_len) s[n++] = '0';
  while (n--) writeChar(s[n]);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
inline void writeDouble(long double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeUInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = std::min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = std::min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
}  // namespace fastinput
namespace bigint {
class big_integer {
 public:
  big_integer();
  big_integer(const big_integer &b);
  big_integer(int b);
  big_integer(uint32_t b);
  explicit big_integer(std::string const &s);
  ~big_integer();
  big_integer &operator=(const big_integer &other);
  big_integer &operator+=(const big_integer &rhs);
  big_integer &operator-=(const big_integer &rhs);
  big_integer &operator*=(const big_integer &rhs);
  big_integer &operator/=(const big_integer &rhs);
  big_integer &operator%=(const big_integer &rhs);
  big_integer &operator&=(const big_integer &rhs);
  big_integer &operator|=(const big_integer &rhs);
  big_integer &operator^=(const big_integer &rhs);
  big_integer &operator<<=(int rhs);
  big_integer &operator>>=(int rhs);
  big_integer operator+() const;
  big_integer operator-() const;
  big_integer operator~() const;
  big_integer &operator++();
  big_integer operator++(int);
  big_integer &operator--();
  big_integer operator--(int);
  friend bool operator==(const big_integer &a, const big_integer &b);
  friend bool operator!=(const big_integer &a, const big_integer &b);
  friend bool operator<(const big_integer &a, const big_integer &b);
  friend bool operator>(const big_integer &a, const big_integer &b);
  friend bool operator<=(const big_integer &a, const big_integer &b);
  friend bool operator>=(const big_integer &a, const big_integer &b);
  friend big_integer operator+(big_integer a, const big_integer &b);
  friend big_integer operator-(big_integer a, const big_integer &b);
  friend big_integer operator*(const big_integer &a, const big_integer &b);
  friend big_integer operator/(big_integer a, const big_integer &b);
  friend big_integer operator%(big_integer a, const big_integer &b);
  friend big_integer operator&(big_integer a, const big_integer &b);
  friend big_integer operator|(big_integer a, const big_integer &b);
  friend big_integer operator^(big_integer a, const big_integer &b);
  friend big_integer operator<<(big_integer a, int b);
  friend big_integer operator>>(big_integer a, int b);
  friend std::string to_string(big_integer a);

 private:
  size_t size;
  uint32_t *data;
  void resize(size_t nsize);
  void normalize();
  std::pair<big_integer, big_integer> divMod(const big_integer &b);
};
big_integer operator+(big_integer a, const big_integer &b);
big_integer operator-(big_integer a, const big_integer &b);
big_integer operator*(const big_integer &a, const big_integer &b);
big_integer operator/(big_integer a, const big_integer &b);
big_integer operator%(big_integer a, const big_integer &b);
big_integer operator&(big_integer a, const big_integer &b);
big_integer operator|(big_integer a, const big_integer &b);
big_integer operator^(big_integer a, const big_integer &b);
big_integer operator<<(big_integer a, int b);
big_integer operator>>(big_integer a, int b);
bool operator==(const big_integer &a, const big_integer &b);
bool operator!=(const big_integer &a, const big_integer &b);
bool operator<(const big_integer &a, const big_integer &b);
bool operator>(const big_integer &a, const big_integer &b);
bool operator<=(const big_integer &a, const big_integer &b);
bool operator>=(const big_integer &a, const big_integer &b);
std::string to_string(big_integer a);
std::istream &operator>>(std::istream &in, big_integer &a);
std::ostream &operator<<(std::ostream &out, const big_integer &a);
static const uint32_t BASE = UINT32_MAX;
static uint32_t filler(uint32_t x) { return (x >> 31 ? BASE : 0); }
static int maxbit(uint32_t n) {
  int temp = -1;
  while (n) {
    n >>= 1;
    ++temp;
  }
  return temp;
}
big_integer::big_integer() : big_integer(0) {}
big_integer::big_integer(const big_integer &b)
    : size(b.size), data(new uint32_t[b.size]) {
  std::copy(b.data, b.data + size, data);
}
big_integer::big_integer(const std::string &s) : big_integer(0) {
  bool neg = s[0] == '-';
  for (size_t i = neg; i < s.size(); ++i) {
    *this *= 10;
    *this += s[i] - '0';
  }
  if (neg) *this = -*this;
}
big_integer::big_integer(int b) : size(1), data(new uint32_t[1]) {
  data[0] = b;
}
big_integer::big_integer(uint32_t b) {
  if (b < (uint32_t)1 << 31) {
    size = 1;
    data = new uint32_t[1];
    data[0] = b;
  } else {
    size = 2;
    data = new uint32_t[2];
    data[0] = b;
    data[1] = 0;
  }
}
big_integer::~big_integer() { delete[] data; }
big_integer &big_integer::operator=(const big_integer &b) {
  uint32_t *ndata = new uint32_t[b.size];
  std::copy(b.data, b.data + b.size, ndata);
  delete[] data;
  size = b.size;
  data = ndata;
  return *this;
}
big_integer &big_integer::operator+=(const big_integer &b) {
  return *this = *this + b;
}
big_integer &big_integer::operator-=(const big_integer &b) {
  return *this = *this - b;
}
big_integer &big_integer::operator*=(const big_integer &b) {
  return *this = *this * b;
}
big_integer &big_integer::operator/=(const big_integer &b) {
  return *this = *this / b;
}
big_integer &big_integer::operator%=(const big_integer &b) {
  return *this = *this % b;
}
big_integer &big_integer::operator&=(const big_integer &b) {
  if (size < b.size) resize(b.size);
  for (size_t i = 0; i < b.size; ++i) data[i] &= b.data[i];
  const uint32_t fill = filler(b.data[b.size - 1]);
  for (size_t i = b.size; i < size; ++i) data[i] &= fill;
  normalize();
  return *this;
}
big_integer &big_integer::operator|=(const big_integer &b) {
  if (size < b.size) resize(b.size);
  for (size_t i = 0; i < b.size; ++i) data[i] |= b.data[i];
  const uint32_t fill = filler(b.data[b.size - 1]);
  for (size_t i = b.size; i < size; ++i) data[i] |= fill;
  normalize();
  return *this;
}
big_integer &big_integer::operator^=(const big_integer &b) {
  if (size < b.size) resize(b.size);
  for (size_t i = 0; i < b.size; ++i) data[i] ^= b.data[i];
  uint32_t fill = filler(b.data[b.size - 1]);
  for (size_t i = b.size; i < size; ++i) data[i] ^= fill;
  normalize();
  return *this;
}
big_integer &big_integer::operator<<=(int b) {
  if (b < 0) return *this >>= -b;
  size_t bc = b >> 5, br = b & 31;
  resize(size + bc + 1);
  for (size_t i = size - 1; i != (size_t)-1; --i)
    data[i] = (i >= bc ? data[i - bc] : 0);
  if (br != 0)
    for (size_t i = size - 1; i != (size_t)-1; --i) {
      data[i] <<= br;
      if (i != 0) data[i] |= (data[i - 1] >> (32 - br));
    }
  normalize();
  return *this;
}
big_integer &big_integer::operator>>=(int b) {
  if (b < 0) return *this <<= -b;
  uint32_t as = filler(data[size - 1]);
  size_t bc = b >> 5, br = b & 31;
  for (size_t i = 0; i < size; ++i)
    data[i] = (i + bc < size ? data[i + bc] : as);
  if (br != 0)
    for (size_t i = 0; i < size; ++i) {
      data[i] >>= br;
      data[i] |= (i + 1 == size ? as : data[i + 1]) << (32 - br);
    }
  normalize();
  return *this;
}
big_integer big_integer::operator+() const { return *this; }
big_integer big_integer::operator-() const {
  big_integer b = ~*this;
  return ++b;
}
big_integer big_integer::operator~() const {
  big_integer r;
  r.resize(size);
  for (size_t i = 0; i < size; ++i) r.data[i] = ~data[i];
  return r;
}
big_integer &big_integer::operator++() { return *this += 1; }
big_integer &big_integer::operator--() { return *this -= 1; }
big_integer big_integer::operator++(int) {
  big_integer a = *this;
  ++*this;
  return a;
}
big_integer big_integer::operator--(int) {
  big_integer a = *this;
  --*this;
  return a;
}
big_integer operator+(big_integer a, const big_integer &b) {
  if (a.size < b.size) a.resize(b.size);
  uint32_t carry = 0;
  uint32_t afill = filler(a.data[a.size - 1]);
  uint32_t bfill = filler(b.data[b.size - 1]);
  for (size_t i = 0; i < b.size; ++i) {
    uint64_t sum = (uint64_t)a.data[i] + b.data[i] + carry;
    a.data[i] = (uint32_t)sum;
    carry = sum >> 32;
  }
  for (size_t i = b.size; i < a.size && bfill + carry; ++i) {
    uint64_t sum = (uint64_t)a.data[i] + bfill + carry;
    a.data[i] = (uint32_t)sum;
    carry = sum >> 32;
  }
  uint32_t newfill = filler(a.data[a.size - 1]);
  if (afill + bfill + carry != newfill) {
    a.resize(a.size + 1);
    a.data[a.size - 1] = afill + bfill + carry;
  }
  a.normalize();
  return a;
}
big_integer operator-(big_integer a, const big_integer &b) {
  if (a.size < b.size) a.resize(b.size);
  uint32_t carry = 0;
  uint32_t afill = filler(a.data[a.size - 1]);
  uint32_t bfill = filler(b.data[b.size - 1]);
  for (size_t i = 0; i < b.size; ++i) {
    uint64_t diff = (uint64_t)a.data[i] - b.data[i] - carry;
    a.data[i] = (uint32_t)diff;
    carry = diff >> 63;
  }
  for (size_t i = b.size; i < a.size && bfill + carry; ++i) {
    uint64_t diff = (uint64_t)a.data[i] - bfill - carry;
    a.data[i] = (uint32_t)diff;
    carry = diff >> 63;
  }
  uint32_t newfill = filler(a.data[a.size - 1]);
  if (afill - bfill - carry != newfill) {
    a.resize(a.size + 1);
    a.data[a.size - 1] = afill - bfill - carry;
  }
  a.normalize();
  return a;
}
big_integer operator*(const big_integer &a, const big_integer &b) {
  if (a < 0) {
    if (b < 0)
      return (-a) * (-b);
    else
      return -((-a) * b);
  } else if (b < 0)
    return -(a * (-b));
  big_integer r;
  r.resize(a.size + b.size);
  for (size_t i = 0; i < a.size; ++i) {
    uint32_t carry = 0;
    for (size_t j = 0; j < b.size; ++j) {
      uint64_t res = (uint64_t)a.data[i] * b.data[j] + carry + r.data[i + j];
      r.data[i + j] = (uint32_t)res;
      carry = res >> 32;
    }
    for (size_t j = b.size; i + j < r.size && carry; ++j) {
      uint64_t res = (uint64_t)carry + r.data[i + j];
      r.data[i + j] = (uint32_t)res;
      carry = res >> 32;
    }
  }
  r.normalize();
  return r;
}
std::pair<big_integer, big_integer> big_integer::divMod(const big_integer &b) {
  if (*this < b) return {0, *this};
  if (b.size == 1 || b.size == 2 && b.data[1] == 0) {
    uint32_t carry = 0;
    for (uint32_t i = size; i--;) {
      uint64_t cur = data[i] + carry * (1LL << 32);
      data[i] = (uint32_t)(cur / b.data[0]);
      carry = (uint32_t)(cur % b.data[0]);
    }
    normalize();
    return {*this, carry};
  }
  if (b.data[b.size - 1] != 0) {
    int shift = 31 - maxbit(b.data[b.size - 1]);
    auto qr = (*this << shift).divMod(b << shift);
    return {qr.first, qr.second >> shift};
  }
  size_t m = size - (data[size - 1] == 0);
  size_t n = b.size - (b.data[b.size - 1] == 0);
  m -= n;
  big_integer q;
  q.resize(m + 2);
  if (*this >= (b << (m * 32))) {
    q.data[m] = 1;
    *this -= (b << (m * 32));
  }
  for (size_t j = m; j--;) {
    if (n + j >= size) continue;
    uint64_t temp =
        ((static_cast<uint64_t>(data[n + j]) << 32) + data[n + j - 1]) /
        b.data[n - 1];
    if (temp >> 32) {
      q.data[j] = BASE;
    } else {
      q.data[j] = static_cast<uint32_t>(temp);
    }
    *this -= q.data[j] * (b << (j * 32));
    while (*this < 0) {
      --q.data[j];
      *this += (b << (j * 32));
    }
  }
  q.normalize();
  normalize();
  return {q, *this};
}
big_integer operator/(big_integer a, const big_integer &b) {
  if (a < 0)
    if (b < 0)
      return (-a) / (-b);
    else
      return -((-a) / b);
  else if (b < 0)
    return -(a / (-b));
  return a.divMod(b).first;
}
big_integer operator%(big_integer a, const big_integer &b) {
  if (a < 0)
    if (b < 0)
      return -(-a) % (-b);
    else
      return -((-a) % b);
  else if (b < 0)
    return (a % (-b));
  return a.divMod(b).second;
}
big_integer operator&(big_integer a, const big_integer &b) { return a &= b; }
big_integer operator|(big_integer a, const big_integer &b) { return a |= b; }
big_integer operator^(big_integer a, const big_integer &b) { return a ^= b; }
big_integer operator<<(big_integer a, int b) { return a <<= b; }
big_integer operator>>(big_integer a, int b) { return a >>= b; }
bool operator==(const big_integer &a, const big_integer &b) {
  for (size_t i = 0; i < std::min(a.size, b.size); ++i)
    if (a.data[i] != b.data[i]) return false;
  uint32_t afill = filler(a.data[a.size - 1]);
  for (size_t i = a.size; i < b.size; ++i)
    if (afill != b.data[i]) return false;
  uint32_t bfill = filler(b.data[b.size - 1]);
  for (size_t i = b.size; i < a.size; ++i)
    if (bfill != a.data[i]) return false;
  return true;
}
bool operator!=(const big_integer &a, const big_integer &b) {
  return !(a == b);
}
bool operator<(const big_integer &a, const big_integer &b) {
  uint32_t afill = filler(a.data[a.size - 1]);
  uint32_t bfill = filler(b.data[b.size - 1]);
  if (afill != bfill) return afill > bfill;
  for (size_t i = b.size; i-- > a.size;)
    if (afill != b.data[i]) return afill < b.data[i];
  for (size_t i = a.size; i-- > b.size;)
    if (bfill != a.data[i]) return a.data[i] < bfill;
  for (size_t i = std::min(a.size, b.size); i--;)
    if (a.data[i] != b.data[i]) return a.data[i] < b.data[i];
  return false;
}
bool operator>(const big_integer &a, const big_integer &b) { return b < a; }
bool operator<=(const big_integer &a, const big_integer &b) { return !(b < a); }
bool operator>=(const big_integer &a, const big_integer &b) { return !(a < b); }
std::string to_string(big_integer a) {
  if (a == 0) return "0";
  std::string s;
  bool neg = false;
  if (a < 0) {
    neg = true;
    a = -a;
  }
  while (a != 0) {
    auto lr = a.divMod(10);
    s.push_back('0' + static_cast<int>(lr.second.data[0]));
    a = lr.first;
  }
  if (neg) s.push_back('-');
  std::reverse(s.begin(), s.end());
  return s;
}
std::istream &operator>>(std::istream &in, big_integer &a) {
  std::string s;
  in >> s;
  a = big_integer(s);
  return in;
}
std::ostream &operator<<(std::ostream &out, const big_integer &a) {
  return out << to_string(a);
}
void big_integer::resize(size_t nsize) {
  uint32_t *ndata = new uint32_t[nsize];
  std::copy(data, data + std::min(size, nsize), ndata);
  if (nsize > size)
    std::fill(ndata + size, ndata + nsize, filler(data[size - 1]));
  delete[] data;
  size = nsize;
  data = ndata;
}
void big_integer::normalize() {
  uint32_t fill = filler(data[size - 1]);
  for (size_t i = size; i--;)
    if (data[i] != fill || i == 0) {
      if (filler(data[i]) != fill) {
        resize(i + 2);
      } else {
        resize(i + 1);
      }
      return;
    }
}
};  // namespace bigint
using namespace fastinput;
using namespace std;
const int MAX_MEM = 2e8;
int mpos = 0;
char mem[MAX_MEM];
inline void *operator new(size_t n) {
  mpos += n;
  return (void *)(mem + mpos - n);
}
inline void operator delete(void *) noexcept {}
const int N = 2e6;
int a[N];
int main() {
  ::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n = readInt();
  map<int, int> cnt;
  map<int, bigint::big_integer> sum;
  bigint::big_integer sum2 = 0;
  bigint::big_integer ans = 0;
  for (int i = 0; i < n; ++i) {
    int val = readInt();
    bigint::big_integer x = i;
    x -= cnt[val - 1];
    x -= cnt[val];
    x -= cnt[val + 1];
    bigint::big_integer keep = sum2;
    sum2 -= sum[val - 1];
    sum2 -= sum[val];
    sum2 -= sum[val + 1];
    ans += sum2 - x * val;
    sum2 = keep + val;
    sum[val] += val;
    cnt[val]++;
  }
  cout << -ans << endl;
  return 0;
}
