#include <bits/stdc++.h>
using namespace std;
int mat[403][403][403];
vector<int> city;
int fun(int s, int f, int r) {
  if (s == f) {
    return mat[s][f][r] = 0;
  }
  if (mat[s][f][r] != 0) {
    return mat[s][f][r];
  }
  if (s + 1 == f || r == 0) {
    return mat[s][f][r] = city[f] - city[s];
  }
  int opt = city[s] + (city[f] - city[s]) / (r + 1);
  int pos =
      lower_bound(city.begin() + s, city.begin() + f + 1, opt) - city.begin();
  mat[s][f][r] = max(fun(pos, f, r - 1), city[pos] - city[s]);
  return mat[s][f][r];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long ans = 0;
  int no_cities, no_vehicle;
  cin >> no_cities >> no_vehicle;
  city.push_back(0);
  for (int i = 1; i <= no_cities; ++i) {
    int b;
    cin >> b;
    city.push_back(b);
  }
  for (int i = 0; i < no_vehicle; ++i) {
    int start, finish, costperkm, refuel_count;
    cin >> start >> finish >> costperkm >> refuel_count;
    long long vol_curr_vehicle =
        (long long)fun(start, finish, refuel_count) * (long long)costperkm;
    ans = max(ans, vol_curr_vehicle);
  }
  printf("%lld", ans);
  return 0;
}
