#include <bits/stdc++.h>
using namespace std;
const int N = 401;
const int M = 250001;
int a[N], s[M], f[M], c[M], r[M];
vector<int> _s;
int remain[N][N];
int need[N][N];
int n, m;
bool cmp(int i, int j) { return s[i] < s[j]; }
int calculate_remain(int i, int j, int re);
int calculate_need(int i, int j, int re) {
  if (need[j][re] != -1) return need[j][re];
  if (i == j) return need[j][re] = 0;
  int nd;
  if (re == 0) {
    nd = a[j] - a[i];
    remain[j][re] = 0;
  } else if (calculate_remain(i, j - 1, re) >= a[j] - a[j - 1]) {
    nd = calculate_need(i, j - 1, re);
    remain[j][re] = remain[j - 1][re] - a[j] + a[j - 1];
  } else {
    int w = j - 1;
    while (w > i &&
           max(calculate_need(i, w, re - 1), a[j] - a[w]) >=
               max(calculate_need(i, w - 1, re - 1), a[j] - a[w - 1])) {
      w--;
    }
    nd = max(calculate_need(i, w, re - 1), a[j] - a[w]);
    remain[j][re] = nd - a[j] + a[w];
  }
  return need[j][re] = nd;
}
int calculate_remain(int i, int j, int re) {
  if (remain[j][re] != -1) return remain[j][re];
  if (i == j) return remain[j][re] = 0;
  calculate_need(i, j, re);
  return remain[j][re];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  _s.push_back(0);
  for (int i = 1; i <= m; i++) {
    _s.push_back(i);
    cin >> s[i] >> f[i] >> c[i] >> r[i];
  }
  sort(_s.begin() + 1, _s.end(), cmp);
  memset(remain, -1, sizeof(remain));
  memset(need, -1, sizeof(need));
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    if (i >= 2 && s[_s[i]] != s[_s[i - 1]]) {
      memset(remain, -1, sizeof(remain));
      memset(need, -1, sizeof(need));
    }
    ans = max(ans, (long long)calculate_need(s[_s[i]], f[_s[i]], r[_s[i]]) *
                       c[_s[i]]);
  }
  cout << ans;
  return 0;
}
