#include <bits/stdc++.h>
using namespace std;
int f[405][405][405], a4, a[405];
int n, m, a1, a2, a3, pos;
long long gets() {
  long long v = 0;
  bool f = 0;
  char ch;
  while (!isdigit(ch)) {
    f |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    v = (v << 3) + (v << 1) + ch - 48;
    ch = getchar();
  }
  return f ? -v : v;
}
int main() {
  n = gets(), m = gets();
  for (int i = 1; i <= n; i++) a[i] = gets();
  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 k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      pos = i;
      for (int j = i + 1; j <= n; j++) {
        while (pos < j && max(f[i][pos][k - 1], a[j] - a[pos]) >
                              max(f[i][pos + 1][k - 1], a[j] - a[pos + 1]))
          pos++;
        f[i][j][k] = max(f[i][pos][k - 1], a[j] - a[pos]);
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    a1 = gets(), a2 = gets(), a4 = gets(), a3 = gets();
    ans = max(ans, (long long)f[a1][a2][a3] * (long long)a4);
  }
  printf("%I64d\n", ans);
  return 0;
}
