#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
int n, m, a[410], f[401][401][401];
long long ans;
inline int work(int i, int j, int op) {
  int l = i + op + 1, r = j - 1;
  while (l < r) {
    int mid = l + r + 1 >> 1;
    if (f[i][mid][op] <= f[mid][j][0])
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  n = read(), m = read();
  memset(f, 0x3f3f3f3f, sizeof(f));
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) f[i][j][0] = a[j] - a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 2; j <= n; j++) {
      for (int k = 1; k <= j - i - 1; k++) {
        int tmp = work(i, j, k - 1);
        f[i][j][k] = min(f[i][j][k], f[tmp][j][0]);
        f[i][j][k] = min(f[i][j][k], f[i][tmp + 1][k - 1]);
      }
    }
  }
  long long x, y, c, k;
  for (int i = 1; i <= m; i++) {
    x = read(), y = read(), c = read(), k = min(y - x - 1ll, read());
    ans = max(ans, 1ll * f[x][y][k] * c);
  }
  cout << ans;
  return 0;
}
